protected static AttributeTransformationDescriptionBuilderRegistry mergeRegistries(AttributeTransformationDescriptionBuilderRegistry one, AttributeTransformationDescriptionBuilderRegistry two) { final AttributeTransformationDescriptionBuilderRegistry result = new AttributeTransformationDescriptionBuilderRegistry(); result.allAttributes.addAll(one.allAttributes); result.allAttributes.addAll(two.allAttributes); result.attributeRestrictions.putAll(one.attributeRestrictions); result.attributeRestrictions.putAll(two.attributeRestrictions); result.discardedAttributes.putAll(one.discardedAttributes); result.discardedAttributes.putAll(two.discardedAttributes); result.renamedAttributes.putAll(one.renamedAttributes); result.renamedAttributes.putAll(two.renamedAttributes); result.convertedAttributes.putAll(one.convertedAttributes); result.convertedAttributes.putAll(two.convertedAttributes); return result; }
public T addRenames(Map<String, String> renames) { for (Map.Entry<String, String> rename : renames.entrySet()) { registry.addRenamedAttribute(rename.getKey(), rename.getValue()); } return thisBuilder(); }
void addAttributeConverter(String attributeName, AttributeConverter attributeConverter) { addToAllAttributes(attributeName); convertedAttributes.put(attributeName, attributeConverter); }
final Map<String, AttributeTransformationDescription> attributes = registry.buildAttributes();
final Map<String, AttributeTransformationDescription> attributes = registry.buildAttributes();
/** * Build the default transformation description. * * @param discardPolicy the discard policy to use * @param inherited whether the definition is inherited * @param registry the attribute transformation rules for the resource * @param discardedOperations the discarded operations * @return the transformation description */ protected TransformationDescription buildDefault(final DiscardPolicy discardPolicy, boolean inherited, final AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry registry, List<String> discardedOperations) { // Build attribute rules final Map<String, AttributeTransformationDescription> attributes = registry.buildAttributes(); // Create operation transformers final Map<String, OperationTransformer> operations = buildOperationTransformers(registry); // Process children final List<TransformationDescription> children = buildChildren(); if (discardPolicy == DiscardPolicy.NEVER) { // TODO override more global operations? if(! operations.containsKey(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION)) { operations.put(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION, OperationTransformationRules.createWriteOperation(attributes)); } if(! operations.containsKey(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION)) { operations.put(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION, OperationTransformationRules.createUndefinedOperation(attributes)); } } // Create the description return new TransformingDescription(pathElement, pathAddressTransformer, discardPolicy, inherited, resourceTransformer, attributes, operations, children, discardedOperations); }
/** * Build the default transformation description. * * @param discardPolicy the discard policy to use * @param inherited whether the definition is inherited * @param registry the attribute transformation rules for the resource * @param discardedOperations the discarded operations * @return the transformation description */ protected TransformationDescription buildDefault(final DiscardPolicy discardPolicy, boolean inherited, final AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry registry, List<String> discardedOperations) { // Build attribute rules final Map<String, AttributeTransformationDescription> attributes = registry.buildAttributes(); // Create operation transformers final Map<String, OperationTransformer> operations = buildOperationTransformers(registry); // Process children final List<TransformationDescription> children = buildChildren(); if (discardPolicy == DiscardPolicy.NEVER) { // TODO override more global operations? if(! operations.containsKey(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION)) { operations.put(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION, OperationTransformationRules.createWriteOperation(attributes)); } if(! operations.containsKey(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION)) { operations.put(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION, OperationTransformationRules.createUndefinedOperation(attributes)); } } // Create the description return new TransformingDescription(pathElement, pathAddressTransformer, discardPolicy, inherited, resourceTransformer, attributes, operations, children, discardedOperations); }
protected OperationTransformer createTransformer(final AttributeTransformationDescriptionBuilderRegistry resourceRegistry) { final AttributeTransformationDescriptionBuilderRegistry registry = resultingRegistry(resourceRegistry); final Map<String, AttributeTransformationDescription> descriptions = registry.buildAttributes(); if(WRITE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom write-attribute operation final TransformationRule first = new OperationTransformationRules.WriteAttributeRule(descriptions); return createTransformer(first); } else if(UNDEFINE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom undefine-attribute operation final TransformationRule first = new OperationTransformationRules.UndefineAttributeRule(descriptions); return createTransformer(first); } else { final AttributeTransformationRule first = new AttributeTransformationRule(descriptions); return createTransformer(first); } }
protected OperationTransformer createTransformer(final AttributeTransformationDescriptionBuilderRegistry resourceRegistry) { final AttributeTransformationDescriptionBuilderRegistry registry = resultingRegistry(resourceRegistry); final Map<String, AttributeTransformationDescription> descriptions = registry.buildAttributes(); if(WRITE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom write-attribute operation final TransformationRule first = new OperationTransformationRules.WriteAttributeRule(descriptions); return createTransformer(first); } else if(UNDEFINE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom undefine-attribute operation final TransformationRule first = new OperationTransformationRules.UndefineAttributeRule(descriptions); return createTransformer(first); } else { final AttributeTransformationRule first = new AttributeTransformationRule(descriptions); return createTransformer(first); } }
protected OperationTransformer createTransformer(final AttributeTransformationDescriptionBuilderRegistry resourceRegistry) { final AttributeTransformationDescriptionBuilderRegistry registry = resultingRegistry(resourceRegistry); final Map<String, AttributeTransformationDescription> descriptions = registry.buildAttributes(); if(WRITE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom write-attribute operation final TransformationRule first = new OperationTransformationRules.WriteAttributeRule(descriptions); return createTransformer(first); } else if(UNDEFINE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom undefine-attribute operation final TransformationRule first = new OperationTransformationRules.UndefineAttributeRule(descriptions); return createTransformer(first); } else { final AttributeTransformationRule first = new AttributeTransformationRule(descriptions); return createTransformer(first); } }
protected OperationTransformer createTransformer(final AttributeTransformationDescriptionBuilderRegistry resourceRegistry) { final AttributeTransformationDescriptionBuilderRegistry registry = resultingRegistry(resourceRegistry); final Map<String, AttributeTransformationDescription> descriptions = registry.buildAttributes(); if(WRITE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom write-attribute operation final TransformationRule first = new OperationTransformationRules.WriteAttributeRule(descriptions); return createTransformer(first); } else if(UNDEFINE_ATTRIBUTE_OPERATION.equals(operationName)) { // Custom undefine-attribute operation final TransformationRule first = new OperationTransformationRules.UndefineAttributeRule(descriptions); return createTransformer(first); } else { final AttributeTransformationRule first = new AttributeTransformationRule(descriptions); return createTransformer(first); } }
protected static AttributeTransformationDescriptionBuilderRegistry mergeRegistries(AttributeTransformationDescriptionBuilderRegistry one, AttributeTransformationDescriptionBuilderRegistry two) { final AttributeTransformationDescriptionBuilderRegistry result = new AttributeTransformationDescriptionBuilderRegistry(); result.allAttributes.addAll(one.allAttributes); result.allAttributes.addAll(two.allAttributes); result.attributeRestrictions.putAll(one.attributeRestrictions); result.attributeRestrictions.putAll(two.attributeRestrictions); result.discardedAttributes.putAll(one.discardedAttributes); result.discardedAttributes.putAll(two.discardedAttributes); result.renamedAttributes.putAll(one.renamedAttributes); result.renamedAttributes.putAll(two.renamedAttributes); result.convertedAttributes.putAll(one.convertedAttributes); result.convertedAttributes.putAll(two.convertedAttributes); return result; }
protected static AttributeTransformationDescriptionBuilderRegistry mergeRegistries(AttributeTransformationDescriptionBuilderRegistry one, AttributeTransformationDescriptionBuilderRegistry two) { final AttributeTransformationDescriptionBuilderRegistry result = new AttributeTransformationDescriptionBuilderRegistry(); result.allAttributes.addAll(one.allAttributes); result.allAttributes.addAll(two.allAttributes); result.attributeRestrictions.putAll(one.attributeRestrictions); result.attributeRestrictions.putAll(two.attributeRestrictions); result.discardedAttributes.putAll(one.discardedAttributes); result.discardedAttributes.putAll(two.discardedAttributes); result.renamedAttributes.putAll(one.renamedAttributes); result.renamedAttributes.putAll(two.renamedAttributes); result.convertedAttributes.putAll(one.convertedAttributes); result.convertedAttributes.putAll(two.convertedAttributes); return result; }
protected static AttributeTransformationDescriptionBuilderRegistry mergeRegistries(AttributeTransformationDescriptionBuilderRegistry one, AttributeTransformationDescriptionBuilderRegistry two) { final AttributeTransformationDescriptionBuilderRegistry result = new AttributeTransformationDescriptionBuilderRegistry(); result.allAttributes.addAll(one.allAttributes); result.allAttributes.addAll(two.allAttributes); result.attributeRestrictions.putAll(one.attributeRestrictions); result.attributeRestrictions.putAll(two.attributeRestrictions); result.discardedAttributes.putAll(one.discardedAttributes); result.discardedAttributes.putAll(two.discardedAttributes); result.renamedAttributes.putAll(one.renamedAttributes); result.renamedAttributes.putAll(two.renamedAttributes); result.convertedAttributes.putAll(one.convertedAttributes); result.convertedAttributes.putAll(two.convertedAttributes); return result; }
protected OperationTransformationOverrideBuilderImpl(final String operationName, final ResourceTransformationDescriptionBuilder builder) { super(builder, new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry()); this.operationName = operationName; }
protected OperationTransformationOverrideBuilderImpl(final String operationName, final ResourceTransformationDescriptionBuilder builder) { super(builder, new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry()); this.operationName = operationName; }
void addAttributeConverter(String attributeName, AttributeConverter attributeConverter) { addToAllAttributes(attributeName); convertedAttributes.put(attributeName, attributeConverter); }
void addAttributeConverter(String attributeName, AttributeConverter attributeConverter) { addToAllAttributes(attributeName); convertedAttributes.put(attributeName, attributeConverter); }
protected OperationTransformationOverrideBuilderImpl(final String operationName, final ResourceTransformationDescriptionBuilder builder) { super(builder, new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry()); this.operationName = operationName; }
@Override public T setDiscard(DiscardAttributeChecker discardChecker, String... discardedAttributes) { String[] useDefs = discardedAttributes; for (String attrName : useDefs) { registry.setDiscardedAttribute(discardChecker, attrName); } return thisBuilder(); }