| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
package org.org.usurper.setup; |
| 20 | |
|
| 21 | |
import java.util.Collections; |
| 22 | |
import java.util.HashMap; |
| 23 | |
import java.util.Map; |
| 24 | |
|
| 25 | |
import org.org.usurper.handlers.IHandler; |
| 26 | |
import org.org.usurper.handlers.basic.AbstractPropertyTypeHandler; |
| 27 | |
import org.org.usurper.handlers.basic.AbstractSpecificPropertyHandler; |
| 28 | |
import org.org.usurper.handlers.basic.ArrayHandler; |
| 29 | |
import org.org.usurper.handlers.basic.EnumHandler; |
| 30 | |
import org.org.usurper.model.ITargetDefinition; |
| 31 | |
import org.org.usurper.model.PropertyTypeDefinition; |
| 32 | |
import org.org.usurper.model.SpecificPropertyDefinition; |
| 33 | |
import org.org.usurper.setup.constants.OnMissingHandlers; |
| 34 | |
import org.org.usurper.setup.constants.PropertyWritingMechanism; |
| 35 | |
import org.org.usurper.utils.UsurperGeneratorSetupUtils; |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
public class ImmutableUsurperGeneratorSetup implements IUsurperGeneratorSetup { |
| 44 | |
private Map<PropertyTypeDefinition, AbstractPropertyTypeHandler> propertyTypeHandlersMap; |
| 45 | |
private Map<SpecificPropertyDefinition, AbstractSpecificPropertyHandler> specificPropertyHandlersMap; |
| 46 | |
private ArrayHandler arrayHandler; |
| 47 | |
private EnumHandler enumHandler; |
| 48 | |
private OnMissingHandlers onMissingHandlers; |
| 49 | |
private PropertyWritingMechanism propertyWritingMechanism; |
| 50 | |
private ICountCallback countCallback; |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public ImmutableUsurperGeneratorSetup(Map<PropertyTypeDefinition, AbstractPropertyTypeHandler> propertyTypeHandlersMap, Map<SpecificPropertyDefinition, AbstractSpecificPropertyHandler> specificPropertyHandlersMap, ArrayHandler arrayHandler, EnumHandler enumHandler, OnMissingHandlers onMissingHandlers, PropertyWritingMechanism propertyWritingMechanism, ICountCallback countCallback) { |
| 64 | 356 | super(); |
| 65 | 356 | this.propertyTypeHandlersMap = Collections.unmodifiableMap(propertyTypeHandlersMap); |
| 66 | 356 | this.specificPropertyHandlersMap = Collections.unmodifiableMap(specificPropertyHandlersMap); |
| 67 | 356 | this.arrayHandler = arrayHandler; |
| 68 | 356 | this.enumHandler = enumHandler; |
| 69 | 356 | this.onMissingHandlers = onMissingHandlers; |
| 70 | 356 | this.propertyWritingMechanism = propertyWritingMechanism; |
| 71 | 356 | this.countCallback = countCallback; |
| 72 | 356 | } |
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
public Map<PropertyTypeDefinition, AbstractPropertyTypeHandler> getPropertyTypeHandlersMap() { |
| 78 | 0 | return propertyTypeHandlersMap; |
| 79 | |
} |
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
public Map<SpecificPropertyDefinition, AbstractSpecificPropertyHandler> getSpecificPropertyHandlersMap() { |
| 85 | 0 | return specificPropertyHandlersMap; |
| 86 | |
} |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
public ArrayHandler getArrayHandler() { |
| 92 | 13 | return arrayHandler; |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public EnumHandler getEnumHandler() { |
| 99 | 43 | return enumHandler; |
| 100 | |
} |
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
public OnMissingHandlers getOnMissingHandlers() { |
| 106 | 3 | return onMissingHandlers; |
| 107 | |
} |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
public PropertyWritingMechanism getPropertyWritingMechanism() { |
| 113 | 6973 | return propertyWritingMechanism; |
| 114 | |
} |
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
public ICountCallback getCountCallback() { |
| 120 | 26 | return countCallback; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
public Map<ITargetDefinition, IHandler> getAllHandlers() { |
| 127 | 850 | Map<ITargetDefinition, IHandler> result = new HashMap<ITargetDefinition, IHandler>(); |
| 128 | 850 | result.putAll(specificPropertyHandlersMap); |
| 129 | 850 | result.putAll(propertyTypeHandlersMap); |
| 130 | 850 | return Collections.unmodifiableMap(result); |
| 131 | |
} |
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
public boolean hasPropertyTypeHandler(PropertyTypeDefinition propertyTypeDefinition) { |
| 137 | 0 | return this.propertyTypeHandlersMap.containsKey(propertyTypeDefinition); |
| 138 | |
} |
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
public AbstractPropertyTypeHandler getPropertyTypeHandler(PropertyTypeDefinition propertyTypeDefinition) { |
| 144 | 7065 | return this.propertyTypeHandlersMap.get(propertyTypeDefinition); |
| 145 | |
} |
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
public boolean hasSpecificPropertyHandler(SpecificPropertyDefinition specificPropertyDefinition) { |
| 151 | 6964 | return this.specificPropertyHandlersMap.containsKey(specificPropertyDefinition); |
| 152 | |
} |
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
public AbstractSpecificPropertyHandler getSpecificPropertyHandler(SpecificPropertyDefinition specificPropertyDefinition) { |
| 158 | 14 | return this.specificPropertyHandlersMap.get(specificPropertyDefinition); |
| 159 | |
} |
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
public String toStringRepresentation() { |
| 165 | 0 | return UsurperGeneratorSetupUtils.buildStringRepresentation(this); |
| 166 | |
} |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
public String toString() { |
| 172 | 0 | return toStringRepresentation(); |
| 173 | |
} |
| 174 | |
} |