001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau; 014 015/** 016 * Represents a simple bean property value and the meta-data associated with it. 017 */ 018public class BeanPropertyValue implements Comparable<BeanPropertyValue> { 019 020 private final BeanPropertyMeta pMeta; 021 private final String name; 022 private final Object value; 023 private final Throwable thrown; 024 025 /** 026 * Constructor. 027 * 028 * @param pMeta The bean property metadata. 029 * @param name The bean property name. 030 * @param value The bean property value. 031 * @param thrown The exception thrown by calling the property getter. 032 */ 033 public BeanPropertyValue(BeanPropertyMeta pMeta, String name, Object value, Throwable thrown) { 034 this.pMeta = pMeta; 035 this.name = name; 036 this.value = value; 037 this.thrown = thrown; 038 } 039 040 /** 041 * Returns the bean property metadata. 042 * 043 * @return The bean property metadata. 044 */ 045 public final BeanPropertyMeta getMeta() { 046 return pMeta; 047 } 048 049 /** 050 * Returns the bean property metadata. 051 * 052 * @return The bean property metadata. 053 */ 054 public final ClassMeta<?> getClassMeta() { 055 return pMeta.getClassMeta(); 056 } 057 058 /** 059 * Returns the bean property name. 060 * 061 * @return The bean property name. 062 */ 063 public final String getName() { 064 return name; 065 } 066 067 /** 068 * Returns the bean property value. 069 * 070 * @return The bean property value. 071 */ 072 public final Object getValue() { 073 return value; 074 } 075 076 /** 077 * Returns the exception thrown by calling the property getter. 078 * 079 * @return The exception thrown by calling the property getter. 080 */ 081 public final Throwable getThrown() { 082 return thrown; 083 } 084 085 @Override /* Comparable */ 086 public int compareTo(BeanPropertyValue o) { 087 return name.compareTo(o.name); 088 } 089 090 @Override /* Object */ 091 public String toString() { 092 return new ObjectMap() 093 .append("name", name) 094 .append("value", value) 095 .append("type", pMeta.getClassMeta().getInnerClass().getSimpleName()) 096 .toString(); 097 } 098}