Path: blob/master/sourcetools/objectmodel/com/ibm/j9tools/om/Feature.java
6004 views
/*******************************************************************************1* Copyright (c) 2007, 2011 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21package com.ibm.j9tools.om;2223import java.util.Map;24import java.util.Set;2526/**27* @author Gabriel Castro28* @since v1.5.029*/30public class Feature extends FeatureDefinition implements Comparable<Feature> {31private FeatureDefinition featureDefinition;3233/**34* Creates a J9 feature reference with the given id.35*36* @param featureId the id of the feature definition37*/38public Feature(String featureId) {39this.id = featureId;40}4142/**43* Creates a J9 feature reference from the given {@link FeatureDefinition}. The feature ID44* is inherited from the {@link FeatureDefinition}.45*46* @param featureDefinition the parent definition47*/48public Feature(FeatureDefinition featureDefinition) {49this(featureDefinition.getId());50this.setDefinition(featureDefinition);51}5253/**54* Sets this feature's parent {@link FeatureDefinition}.55*56* @param featureDefinition the parent definition57*/58public void setDefinition(FeatureDefinition featureDefinition) {59this.featureDefinition = featureDefinition;60this.complete = true;61}6263/**64* Removes this feature's parent {@link FeatureDefinition}.65*/66public void removeDefinition() {67this.featureDefinition = null;68this.complete = false;69}7071/**72* Does nothing as a {@link Property} cannot be added to a {@link Feature}, only to its73* parent {@link FeatureDefinition}.74*75* @see com.ibm.j9tools.om.FeatureDefinition#addProperty(com.ibm.j9tools.om.Property)76*/77@Override78public void addProperty(Property property) {79}8081/**82* Does nothing as a {@link Property} cannot be added to a {@link Feature}, only to its83* parent {@link FeatureDefinition}.84*85* @see com.ibm.j9tools.om.FeatureDefinition#addAllProperties(java.util.Set)86*/87@Override88public void addAllProperties(Set<String> propertyNames) {89}9091/**92* Does nothing as a {@link Flag} cannot be added to a {@link Feature}, only to its93* parent {@link FeatureDefinition}.94*95* @see com.ibm.j9tools.om.FeatureDefinition#addAllFlags(java.util.Map)96*/97@Override98public void addAllFlags(Map<String, Flag> flags) {99}100101/**102* Does nothing as a {@link Flag} cannot be added to a {@link Feature}, only to its103* parent {@link FeatureDefinition}.104*105* @see com.ibm.j9tools.om.FeatureDefinition#addFlag(com.ibm.j9tools.om.Flag)106*/107@Override108public void addFlag(Flag flag) {109}110111/**112* Does nothing as a {@link Source} cannot be added to a {@link Feature}, only to its113* parent {@link FeatureDefinition}.114*115* @see com.ibm.j9tools.om.FeatureDefinition#addSource(com.ibm.j9tools.om.Source)116*/117@Override118public void addSource(Source source) {119}120121/**122* Retrieves the name of the parent {@link FeatureDefinition} if one is set.123*124* @see com.ibm.j9tools.om.FeatureDefinition#getName()125*/126@Override127public String getName() {128return (complete) ? featureDefinition.getName() : super.getName();129}130131/**132* Retrieves the description of the parent {@link FeatureDefinition} if one is set.133*134* @see com.ibm.j9tools.om.FeatureDefinition#getDescription()135*/136@Override137public String getDescription() {138return (complete) ? featureDefinition.getDescription() : super.getDescription();139}140141/**142* Retrieves the given property from the parent {@link FeatureDefinition} if one is set,143* otherwise it returns null;144*145* @see com.ibm.j9tools.om.FeatureDefinition#getProperty(java.lang.String)146*/147@Override148public Property getProperty(String propertyName) {149return (complete) ? featureDefinition.getProperty(propertyName) : super.getProperty(propertyName);150}151152/**153* Retrieves the properties from the parent {@link FeatureDefinition} if one is set,154* otherwise it returns null;155*156* @see com.ibm.j9tools.om.FeatureDefinition#getProperties()157*/158@Override159public Map<String, Property> getProperties() {160return (complete) ? featureDefinition.getProperties() : super.getProperties();161}162163/**164* Retrieves the given flag from the parent {@link FeatureDefinition} if one is set,165* otherwise it returns null;166*167* @see com.ibm.j9tools.om.FeatureDefinition#getFlag(java.lang.String)168*/169@Override170public Flag getFlag(String flagId) {171return (complete) ? featureDefinition.getFlag(flagId) : super.getFlag(flagId);172}173174/**175* Retrieves the flags from the parent {@link FeatureDefinition} if one is set,176* otherwise it returns null;177*178* @see com.ibm.j9tools.om.FeatureDefinition#getFlags()179*/180@Override181public Map<String, Flag> getFlags() {182return (complete) ? featureDefinition.getFlags() : super.getFlags();183}184185/**186* Retrieves the flags with the given category from the parent {@link FeatureDefinition} if one is set,187* otherwise it returns null;188*189* @see com.ibm.j9tools.om.FeatureDefinition#getFlags(java.lang.String)190*/191@Override192public Map<String, Flag> getFlags(String category) {193return (complete) ? featureDefinition.getFlags(category) : super.getFlags(category);194}195196/**197* Retrieves the given local flag from the parent {@link FeatureDefinition} if one is set,198* otherwise it returns null;199*200* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlag(java.lang.String)201*/202@Override203public Flag getLocalFlag(String flagId) {204return (complete) ? featureDefinition.getLocalFlag(flagId) : super.getLocalFlag(flagId);205}206207/**208* Retrieves the local flags from the parent {@link FeatureDefinition} if one is set,209* otherwise it returns null;210*211* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlags()212*/213@Override214public Map<String, Flag> getLocalFlags() {215return (complete) ? featureDefinition.getLocalFlags() : super.getLocalFlags();216}217218/**219* Retrieves the local flags with the given category from the parent {@link FeatureDefinition} if one is set,220* otherwise it returns null;221*222* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlags(java.lang.String)223*/224@Override225public Map<String, Flag> getLocalFlags(String category) {226return (complete) ? featureDefinition.getLocalFlags(category) : super.getLocalFlags(category);227}228229/**230* Retrieves the given local source from the parent {@link FeatureDefinition} if one is set,231* otherwise it returns null;232*233* @see com.ibm.j9tools.om.FeatureDefinition#getLocalSource(java.lang.String)234*/235@Override236public Source getLocalSource(String sourceId) {237return (complete) ? featureDefinition.getLocalSource(sourceId) : super.getLocalSource(sourceId);238}239240/**241* Retrieves the local sources from the parent {@link FeatureDefinition} if one is set,242* otherwise it returns null;243*244* @see com.ibm.j9tools.om.FeatureDefinition#getLocalSources()245*/246@Override247public Map<String, Source> getLocalSources() {248return (complete) ? featureDefinition.getLocalSources() : super.getLocalSources();249}250251/**252* Retrieves the given source from the parent {@link FeatureDefinition} if one is set,253* otherwise it returns null;254*255* @see com.ibm.j9tools.om.FeatureDefinition#getSource(java.lang.String)256*/257@Override258public Source getSource(String sourceId) {259return (complete) ? featureDefinition.getSource(sourceId) : super.getSource(sourceId);260}261262/**263* @see com.ibm.j9tools.om.FeatureDefinition#getSources()264*/265@Override266public Map<String, Source> getSources() {267return (complete) ? featureDefinition.getSources() : super.getSources();268}269270/**271* Determines if the parent {@link FeatureDefinition} has the given property. If the definition is not272* set it returns null.273*274* @see com.ibm.j9tools.om.FeatureDefinition#hasProperty(java.lang.String)275*/276@Override277public boolean hasProperty(String propertyName) {278return (complete) ? featureDefinition.hasProperty(propertyName) : super.hasProperty(propertyName);279}280281/**282* Determines if the parent {@link FeatureDefinition} has the given flag. If the definition is not283* set it returns null.284*285* @see com.ibm.j9tools.om.FeatureDefinition#hasFlag(java.lang.String)286*/287@Override288public boolean hasFlag(String flagId) {289return (complete) ? featureDefinition.hasFlag(flagId) : super.hasFlag(flagId);290}291292/**293* Determines if the parent {@link FeatureDefinition} has the given local flag. If the definition is not294* set it returns null.295*296* @see com.ibm.j9tools.om.FeatureDefinition#hasLocalFlag(java.lang.String)297*/298@Override299public boolean hasLocalFlag(String flagId) {300return (complete) ? featureDefinition.hasLocalFlag(flagId) : super.hasLocalFlag(flagId);301}302303/**304* Determines if the parent {@link FeatureDefinition} has the given source. If the definition is not305* set it returns null.306*307* @see com.ibm.j9tools.om.FeatureDefinition#hasSource(java.lang.String)308*/309@Override310public boolean hasSource(String sourceId) {311return (complete) ? featureDefinition.hasSource(sourceId) : super.hasSource(sourceId);312}313314/**315* Determines if the parent {@link FeatureDefinition} has the given local source. If the definition is not316* set it returns null.317*318* @see com.ibm.j9tools.om.FeatureDefinition#hasLocalSource(java.lang.String)319*/320@Override321public boolean hasLocalSource(String sourceId) {322return (complete) ? featureDefinition.hasLocalSource(sourceId) : super.hasLocalSource(sourceId);323}324325/**326* Does nothing as a {@link Property} cannot be removed from a {@link Feature}, only from327* a {@link FeatureDefinition}.328*329* @see com.ibm.j9tools.om.FeatureDefinition#removeProperty(com.ibm.j9tools.om.Property)330*/331@Override332public void removeProperty(Property property) {333}334335/**336* Does nothing as a {@link Property} cannot be removed from a {@link Feature}, only from337* a {@link FeatureDefinition}.338*339* @see com.ibm.j9tools.om.FeatureDefinition#removeProperty(java.lang.String)340*/341@Override342public void removeProperty(String propertyName) {343}344345/**346* Does nothing as a {@link Flag} cannot be removed from a {@link Feature}, only from347* a {@link FeatureDefinition}.348*349* @see com.ibm.j9tools.om.FeatureDefinition#removeFlag(com.ibm.j9tools.om.Flag)350*/351@Override352public void removeFlag(Flag flag) {353}354355/**356* Does nothing as a {@link Flag} cannot be removed from a {@link Feature}, only from357* a {@link FeatureDefinition}.358*359* @see com.ibm.j9tools.om.FeatureDefinition#removeFlag(java.lang.String)360*/361@Override362public void removeFlag(String flagId) {363}364365/**366* Does nothing as a {@link Source} cannot be removed from a {@link Feature}, only from367* a {@link FeatureDefinition}.368*369* @see com.ibm.j9tools.om.FeatureDefinition#removeSource(java.lang.String)370*/371@Override372public void removeSource(String sourceId) {373}374375/**376* Does nothing as a {@link Source} cannot be removed from a {@link Feature}, only from377* a {@link FeatureDefinition}.378*379* @see com.ibm.j9tools.om.FeatureDefinition#setDescription(java.lang.String)380*/381@Override382public void setDescription(String description) {383}384385/**386* Does nothing as the name of a {@link Feature} cannot be changed. The name is387* inherited from it's {@link FeatureDefinition}.388*389* @see com.ibm.j9tools.om.FeatureDefinition#setName(java.lang.String)390*/391@Override392public void setName(String name) {393}394395/**396* @see java.lang.Comparable#compareTo(java.lang.Object)397*/398public int compareTo(Feature o) {399return id.compareToIgnoreCase(o.id);400}401402/**403* @see java.lang.Object#equals(java.lang.Object)404*/405@Override406public boolean equals(Object o) {407return (o instanceof Feature) ? id.equals(((Feature) o).id) : false;408}409410}411412413