001/*
002 * Copyright (c) 2016-2017 Chris K Wensel <chris@wensel.net>. All Rights Reserved.
003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
004 *
005 * Project and contact information: http://www.cascading.org/
006 *
007 * This file is part of the Cascading project.
008 *
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *     http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 */
021
022package cascading.management.annotation;
023
024import java.lang.annotation.ElementType;
025import java.lang.annotation.Retention;
026import java.lang.annotation.RetentionPolicy;
027import java.lang.annotation.Target;
028
029/**
030 * Property annotations can be used to send additional information about certain aspects of Cascading classes
031 * to the {@link cascading.management.DocumentService}.  The properties are present at runtime and allow a
032 * DocumentService to inspect, process or persist them.
033 * <p>
034 * Property annotations can be applied to {@link cascading.tap.Tap}s, {@link cascading.scheme.Scheme}s,
035 * and any {@link cascading.operation.Operation} sub-classes (like Function or Aggregator).
036 * <p>
037 * Property annotations can be applied to any method or field members, so that they can be accessed via
038 * java.lang.Class#getMethods() and java.lang.Class.getFields() respectively. If the member is protected/private,
039 * there will be an attempt to bypass the protected/private scope to retrieve the value.
040 * <p>
041 * By default the {@link Visibility} is {@link Visibility#PUBLIC}, and optionality is {@code true}.
042 */
043@Retention(RetentionPolicy.RUNTIME)
044@Target({ElementType.METHOD, ElementType.FIELD})
045public @interface Property
046  {
047  /**
048   * The display name for the property value. Does not need to match the bean property or field name.
049   *
050   * @return the display name
051   */
052  String name();
053
054  /**
055   * The display visibility, see {@link Visibility}.
056   *
057   * @return the display visibility
058   */
059  Visibility visibility() default Visibility.PUBLIC;
060
061  /**
062   * Whether the field name and null should be displayed if the value is {@code null}.
063   * <p>
064   * When {@code true}, no data (field name, visibility, and the {@code null} value are sent to the display. The property
065   * is ignored.
066   *
067   * @return whether the field should be displayed if {@code null}
068   */
069  boolean optional() default true;
070  }