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.annotation; 014 015import java.lang.annotation.*; 016import java.lang.reflect.*; 017 018import org.apache.juneau.*; 019import org.apache.juneau.reflect.*; 020 021/** 022 * A concrete implementation of the {@link ParentProperty} annotation. 023 * 024 * <ul class='seealso'> 025 * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} 026 * </ul> 027 */ 028public class ParentPropertyAnnotation implements ParentProperty { 029 030 private String on = ""; 031 032 /** 033 * Constructor. 034 * 035 * @param on The initial value for the <c>on</c> property. 036 * <br>See {@link ParentProperty#on()} 037 */ 038 public ParentPropertyAnnotation(String on) { 039 on(on); 040 } 041 042 /** 043 * Constructor. 044 * 045 * @param on The initial value for the <c>on</c> property. 046 * <br>See {@link ParentProperty#on()} 047 */ 048 public ParentPropertyAnnotation(Method on) { 049 on(on); 050 } 051 052 /** 053 * Constructor. 054 * 055 * @param on The initial value for the <c>on</c> property. 056 * <br>See {@link ParentProperty#on()} 057 */ 058 public ParentPropertyAnnotation(Field on) { 059 on(on); 060 } 061 062 @Override 063 public Class<? extends Annotation> annotationType() { 064 return ParentProperty.class; 065 } 066 067 @Override 068 public String on() { 069 return on; 070 } 071 072 /** 073 * Sets the <c>on</c> property on this annotation. 074 * 075 * @param value The new value for this property. 076 * @return This object (for method chaining). 077 */ 078 public ParentPropertyAnnotation on(String value) { 079 this.on = value; 080 return this; 081 } 082 083 /** 084 * Sets the <c>on</c> property on this annotation. 085 * 086 * @param value The new value for this property. 087 * @return This object (for method chaining). 088 */ 089 public ParentPropertyAnnotation on(Method value) { 090 this.on = MethodInfo.of(value).getFullName(); 091 return this; 092 } 093 094 /** 095 * Sets the <c>on</c> property on this annotation. 096 * 097 * @param value The new value for this property. 098 * @return This object (for method chaining). 099 */ 100 public ParentPropertyAnnotation on(Field value) { 101 this.on = value.getName(); 102 return this; 103 } 104}