/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. */
  24. package org.hudsonci.api.model;
  25. import java.io.Serializable;
  26. /**
  27. * Represents Properties for Job,
  28. * <p/>
  29. * Date: 9/22/11
  30. *
  31. * @author Nikita Levyankov
  32. */
  33. public interface IProjectProperty<T> extends Serializable {
  34. /**
  35. * Sets key for given property.
  36. *
  37. * @param key key.
  38. */
  39. void setKey(String key);
  40. /**
  41. * @return property key.
  42. */
  43. String getKey();
  44. /**
  45. * Sets the job, which is owner of current property.
  46. *
  47. * @param job {@link ICascadingJob}
  48. */
  49. void setJob(ICascadingJob job);
  50. /**
  51. * Sets property value.
  52. * If property has cascading value and properties' {@link #allowOverrideValue(Object, Object)} method returns true,
  53. * than value will be set to current property.<br/>
  54. * If property doesn't have cascading value, than value will be set directly.
  55. *
  56. * @param value value to set.
  57. */
  58. void setValue(T value);
  59. /**
  60. * Returns original property value.
  61. *
  62. * @return T
  63. */
  64. T getOriginalValue();
  65. /**
  66. * Returns cascading value if any.
  67. *
  68. * @return string.
  69. */
  70. T getCascadingValue();
  71. /**
  72. * @return true if value inherited from cascading project, false - otherwise,
  73. */
  74. boolean isOverridden();
  75. /**
  76. * Returns property value. If originalValue is not null or value was overridden for this
  77. * property - call {@link #getOriginalValue()}, otherwise call {@link #getCascadingValue()}.
  78. *
  79. * @return string.
  80. */
  81. T getValue();
  82. /**
  83. * This value will be taken if both cascading project and current project don't have values. Null by default.
  84. *
  85. * @return value
  86. */
  87. T getDefaultValue();
  88. /**
  89. * Resets value for given job. Default implementation sets Null value and resets propertyOverridden flag to false.
  90. */
  91. void resetValue();
  92. /**
  93. * Returns true, if cascading value should be overridden by candidate value.
  94. *
  95. * @param cascadingValue value from cascading project if any.
  96. * @param candidateValue candidate value.
  97. * @return true if cascading value should be replaced by candidate value.
  98. */
  99. boolean allowOverrideValue(T cascadingValue, T candidateValue);
  100. /**
  101. * Sets the overridden flag.
  102. *
  103. * @param overridden true - mark property as overridden, false - otherwise.
  104. */
  105. void setOverridden(boolean overridden);
  106. /**
  107. * Method that is called while changing cascading parent. Update property internal states.l
  108. */
  109. void onCascadingProjectChanged();
  110. }