PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/hudson-core/src/main/java/org/hudsonci/api/model/IProjectProperty.java

http://github.com/hudson/hudson
Java | 126 lines | 17 code | 16 blank | 93 comment | 0 complexity | cefa66af5bedfc36ce18bc45ee251452 MD5 | raw file
  1/*
  2 * The MIT License
  3 *
  4 * Copyright (c) 2004-2011, Oracle Corporation, Nikita Levyankov
  5 *
  6 * Permission is hereby granted, free of charge, to any person obtaining a copy
  7 * of this software and associated documentation files (the "Software"), to deal
  8 * in the Software without restriction, including without limitation the rights
  9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10 * copies of the Software, and to permit persons to whom the Software is
 11 * furnished to do so, subject to the following conditions:
 12 *
 13 * The above copyright notice and this permission notice shall be included in
 14 * all copies or substantial portions of the Software.
 15 *
 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22 * THE SOFTWARE.
 23 */
 24package org.hudsonci.api.model;
 25
 26import java.io.Serializable;
 27
 28/**
 29 * Represents Properties for Job,
 30 * <p/>
 31 * Date: 9/22/11
 32 *
 33 * @author Nikita Levyankov
 34 */
 35public interface IProjectProperty<T> extends Serializable {
 36
 37    /**
 38     * Sets key for given property.
 39     *
 40     * @param key key.
 41     */
 42    void setKey(String key);
 43
 44    /**
 45     * @return property key.
 46     */
 47    String getKey();
 48
 49    /**
 50     * Sets the job, which is owner of current property.
 51     *
 52     * @param job {@link ICascadingJob}
 53     */
 54    void setJob(ICascadingJob job);
 55
 56    /**
 57     * Sets property value.
 58     * If property has cascading value and properties' {@link #allowOverrideValue(Object, Object)} method returns true,
 59     * than value will be set to current property.<br/>
 60     * If property doesn't have cascading value, than value will be set directly.
 61     *
 62     * @param value value to set.
 63     */
 64    void setValue(T value);
 65
 66    /**
 67     * Returns original property value.
 68     *
 69     * @return T
 70     */
 71    T getOriginalValue();
 72
 73    /**
 74     * Returns cascading value if any.
 75     *
 76     * @return string.
 77     */
 78    T getCascadingValue();
 79
 80    /**
 81     * @return true if value inherited from cascading project, false - otherwise,
 82     */
 83    boolean isOverridden();
 84
 85    /**
 86     * Returns property value. If originalValue is not null or value was overridden for this
 87     * property - call {@link #getOriginalValue()}, otherwise call {@link #getCascadingValue()}.
 88     *
 89     * @return string.
 90     */
 91    T getValue();
 92
 93    /**
 94     * This value will be taken if both cascading project and current project don't have values. Null by default.
 95     *
 96     * @return value
 97     */
 98    T getDefaultValue();
 99
100    /**
101     * Resets value for given job. Default implementation sets Null value and resets propertyOverridden flag to false.
102     */
103    void resetValue();
104
105    /**
106     * Returns true, if cascading value should be overridden by candidate value.
107     *
108     * @param cascadingValue value from cascading project if any.
109     * @param candidateValue candidate value.
110     * @return true if cascading value should be replaced by candidate value.
111     */
112    boolean allowOverrideValue(T cascadingValue, T candidateValue);
113
114    /**
115     * Sets the overridden flag.
116     *
117     * @param overridden true - mark property as overridden, false - otherwise.
118     */
119    void setOverridden(boolean overridden);
120
121    /**
122     * Method that is called while changing cascading parent. Update property internal states.l
123     */
124    void onCascadingProjectChanged();
125
126}