@@ -0,0 +1,2879 @@
+/*%0A * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.%0A *%0A * WSO2 Inc. licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.wso2.carbon.uis.api.util;%0A%0Aimport java.util.Objects;%0Aimport java.util.Optional;%0A%0A/**%0A * Represents an entity that can be overridden by another entity .%0A *%0A * @param %3CT%3E the type of the objects that can be use to override this object%0A * @since 0.12.0%0A */%0Apublic interface Overridable%3CT extends Overridable%3CT%3E%3E %7B%0A%0A    /**%0A     * Overrides this object (base) by the supplied object (override) and returns a new object that represents the%0A     * override.%0A     *%0A     * @param override the object that overrides this object%0A     * @return new object that represents the override%0A     * @throws IllegalArgumentException if this object cannot be overridden the the supplied object%0A     */%0A    T override(T override);%0A%0A    /**%0A     * Returns the base object of the override.%0A     *%0A     * @return %7B@code this%7D if has not been overridden, otherwise the base object%0A     */%0A    T getBase();%0A%0A    /**%0A     * Returns the overriding object of the override.%0A     *%0A     * @return the overriding object of has been overridden, otherwise %7B@link Optional#empty() empty%7D%0A     */%0A    default Optional%3CT%3E getOverride() %7B%0A        return Optional.empty();%0A    %7D%0A%0A    /**%0A     * Returns whether this object has been overridden by some other object.%0A     *%0A     * @return %7B@code true%7D if has been overridden, otherwise %7B@code false%7D%0A     */%0A    default boolean hasOverridden() %7B%0A        return this.getOverride().isPresent();%0A    %7D%0A%0A    /**%0A     * Returns whether this object has been overridden by the specified object.%0A     *%0A     * @param other other object to be checked%0A     * @return %7B@code true%7D if has been overridden by the supplied object, otherwise %7B@code false%7D%0A     */%0A    default boolean hasOverriddenBy(T other) %7B%0A        return this.getOverride()%0A                .map(override -%3E Objects.equals(other, override))%0A                .orElse(false);%0A    %7D%0A%0A    /**%0A     * Returns whether this object can be overridden by the specified object.%0A     *%0A     * @param other other object to be checked%0A     * @return %7B@code true%7D if can be overridden, otherwise %7B@code false%7D%0A     */%0A    default boolean canOverrideBy(T other) %7B%0A        return (other != null) && (this.hashCode() == other.hashCode());%0A    %7D%0A%7D%0A

add Overridable interface