public class StateGenerator
extends Object
Generates PropertyState objects given types and pre-existing state. Use this class to generate default state in the ConnectedSystemTemplate.getConfigurationDescriptor(ConfigurationDescriptor, PropertyPath, ExecutionContext) method and IntegrationTemplate.getConfigurationDescriptor(ConfigurationDescriptor, ConfigurationDescriptor, PropertyPath, ExecutionContext) method when the ConfigurationDescriptor is null.
| Constructor and Description |
|---|
StateGenerator(Collection<LocalTypeDescriptor> localTypeDescriptors)
Creates a state generator that can create state for the provided local types.
|
StateGenerator(LocalTypeDescriptor... localTypeDescriptors)
Creates a state generator that can create state for the provided local types.
|
| Modifier and Type | Method and Description |
|---|---|
PropertyState |
generateDefaultState(LocalTypeDescriptor typeDescriptor)
Convenience method for
generateDefaultState(TypeReference) |
PropertyState |
generateDefaultState(TypeReference typeRef)
Generates a default
PropertyState for the provided type. |
protected Object |
generateDefaultValue(TypeReference typeReference,
int level) |
PropertyState |
generateFromExistingState(LocalTypeDescriptor localTypeDescriptor,
PropertyState stateToCast)
Maps properties from the provided state to a new
PropertyState with the given type. |
PropertyState |
generateFromExistingState(LocalTypeDescriptor localTypeDescriptor,
PropertyState oldRootState,
PropertyPath path)
Convenience method for
generateFromExistingState(LocalTypeDescriptor, PropertyState). |
protected Set<String> |
getStateKeysToMaintain(LocalTypeDescriptor localTypeDescriptor,
Map<String,Object> oldStateMap) |
public StateGenerator(LocalTypeDescriptor... localTypeDescriptors)
public StateGenerator(Collection<LocalTypeDescriptor> localTypeDescriptors)
public PropertyState generateFromExistingState(LocalTypeDescriptor localTypeDescriptor, PropertyState oldRootState, PropertyPath path)
generateFromExistingState(LocalTypeDescriptor, PropertyState). Allows specifying path for mapping nested state.localTypeDescriptor - The target type of the stateToCastoldRootState - The root statepath - The path to the state to map to the localTypeDescriptorpath. This method does not return root state.public PropertyState generateFromExistingState(LocalTypeDescriptor localTypeDescriptor, PropertyState stateToCast)
PropertyState with the given type. Extra properties are retained when possible (see shouldKeepOldState(PropertyDescriptor, PropertyState). Any properties that cannot be retained are dropped. On being saved, templates will lose all extra properties.localTypeDescriptor - The target type of the stateToCaststateToCast - The state to map to the localTypeDescriptorpublic PropertyState generateDefaultState(TypeReference typeRef)
PropertyState for the provided type. Default state for SystemTypes will be null. For local types, the default PropertyState.getValue() is a Map of String to PropertyState where they key for each entry is the property's key.
When generating state for a type that references other types, ensure the state generator was constructed with all referenced types.
Use this method to generate initial state for template ConfigurationDescriptors. The provided type should be the root type for your configuration.
typeRef - The type to generate state forpublic PropertyState generateDefaultState(LocalTypeDescriptor typeDescriptor)
generateDefaultState(TypeReference)protected Object generateDefaultValue(TypeReference typeReference, int level)
protected Set<String> getStateKeysToMaintain(LocalTypeDescriptor localTypeDescriptor, Map<String,Object> oldStateMap)
Copyright © 2018-present Appian Corporation. All Rights Reserved.