@Override public void setPriority(RulePriority priority) { // Only override if different than current value, or if already overridden. if (priority != super.getPriority() || this.priority != null) { this.priority = priority; super.setPriority(priority); } }
@Override public void setLanguage(Language language) { // Only override if different than current value, or if already overridden. if (!isSame(language, super.getLanguage()) || this.language != null) { this.language = language; super.setLanguage(language); } }
@Override public void setExternalInfoUrl(String externalInfoUrl) { // Only override if different than current value, or if already overridden. if (!isSame(externalInfoUrl, super.getExternalInfoUrl()) || this.externalInfoUrl != null) { this.externalInfoUrl = externalInfoUrl; super.setExternalInfoUrl(externalInfoUrl); } }
@Override public void setDescription(String description) { // Only override if different than current value, or if already overridden. if (!isSame(description, super.getDescription()) || this.description != null) { this.description = description; super.setDescription(description); } }
@Override public void setMessage(String message) { // Only override if different than current value, or if already overridden. if (!isSame(message, super.getMessage()) || this.message != null) { this.message = message; super.setMessage(message); } }
@Override public void setName(String name) { // Only override if different than current value, or if already overridden. if (!isSame(name, super.getName()) || this.name != null) { this.name = name; super.setName(name); } }
@Override public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { // Only override if different than current value, or if already overridden. if (!isSame(maximumLanguageVersion, super.getMaximumLanguageVersion()) || this.maximumLanguageVersion != null) { this.maximumLanguageVersion = maximumLanguageVersion; super.setMaximumLanguageVersion(maximumLanguageVersion); } }
@Override public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value) { // Only override if different than current value. if (!isSame(super.getProperty(propertyDescriptor), value)) { if (propertyValues == null) { propertyValues = new HashMap<PropertyDescriptor<?>, Object>(); } propertyValues.put(propertyDescriptor, value); super.setProperty(propertyDescriptor, value); } }
@Override public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) throws IllegalArgumentException { // Define on the underlying Rule, where it is impossible to have two // property descriptors with the same name. Therefore, there is no need // to check if the property is already overridden at this level. super.definePropertyDescriptor(propertyDescriptor); if (propertyDescriptors == null) { propertyDescriptors = new ArrayList<PropertyDescriptor<?>>(); } propertyDescriptors.add(propertyDescriptor); }
@Override public void addExample(String example) { // TODO Meaningful override of examples is hard, because they are merely // a list of strings. How does one indicate override of a particular // value? Via index? Rule.setExample(int, String)? But the XML format // does not provide a means of overriding by index, not unless you took // the position in the XML file to indicate corresponding index to // override. But that means you have to override starting from index 0. // This would be so much easier if examples had to have names, like // properties. // Only override if different than current values. if (!contains(super.getExamples(), example)) { if (examples == null) { examples = new ArrayList<String>(1); } // TODO Fix later. To keep example overrides from being unbounded, we're only going to keep // track of the last one. examples.clear(); examples.add(example); super.addExample(example); } }