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 015import org.apache.juneau.collections.*; 016 017/** 018 * Represents a simple bean property value and the meta-data associated with it. 019 */ 020public class BeanPropertyValue implements Comparable<BeanPropertyValue> { 021 022 private final BeanPropertyMeta pMeta; 023 private final String name; 024 private final Object value; 025 private final Throwable thrown; 026 027 /** 028 * Constructor. 029 * 030 * @param pMeta The bean property metadata. 031 * @param name The bean property name. 032 * @param value The bean property value. 033 * @param thrown The exception thrown by calling the property getter. 034 */ 035 public BeanPropertyValue(BeanPropertyMeta pMeta, String name, Object value, Throwable thrown) { 036 this.pMeta = pMeta; 037 this.name = name; 038 this.value = value; 039 this.thrown = thrown; 040 } 041 042 /** 043 * Returns the bean property metadata. 044 * 045 * @return The bean property metadata. 046 */ 047 public final BeanPropertyMeta getMeta() { 048 return pMeta; 049 } 050 051 /** 052 * Returns the bean property metadata. 053 * 054 * @return The bean property metadata. 055 */ 056 public final ClassMeta<?> getClassMeta() { 057 return pMeta.getClassMeta(); 058 } 059 060 /** 061 * Returns the bean property name. 062 * 063 * @return The bean property name. 064 */ 065 public final String getName() { 066 return name; 067 } 068 069 /** 070 * Returns the bean property value. 071 * 072 * @return The bean property value. 073 */ 074 public final Object getValue() { 075 return value; 076 } 077 078 /** 079 * Returns the exception thrown by calling the property getter. 080 * 081 * @return The exception thrown by calling the property getter. 082 */ 083 public final Throwable getThrown() { 084 return thrown; 085 } 086 087 @Override /* Comparable */ 088 public int compareTo(BeanPropertyValue o) { 089 return name.compareTo(o.name); 090 } 091 092 @Override /* Object */ 093 public String toString() { 094 return OMap.of() 095 .a("name", name) 096 .a("value", value) 097 .a("type", pMeta.getClassMeta().getInnerClass().getSimpleName()) 098 .toString(); 099 } 100}