import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.UnionType;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicates;
+
public final class BindingGeneratorImpl implements BindingGenerator {
/**
*/
@Override
public List<Type> generateTypes(final SchemaContext context) {
- if (context == null) {
- throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
- }
- if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain defined modules!");
- }
-
+ Preconditions.checkArgument(context != null,"Schema Context reference cannot be NULL.");
+ Preconditions.checkState(context.getModules() != null,"Schema Context does not contain defined modules.");
final List<Type> generatedTypes = new ArrayList<>();
schemaContext = context;
typeProvider = new TypeProviderImpl(context);
*/
@Override
public List<Type> generateTypes(final SchemaContext context, final Set<Module> modules) {
- if (context == null) {
- throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
- }
- if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain defined modules!");
- }
- if (modules == null) {
- throw new IllegalArgumentException("Sef of Modules cannot be NULL!");
- }
+ Preconditions.checkArgument(context != null,"Schema Context reference cannot be NULL.");
+ Preconditions.checkState(context.getModules() != null,"Schema Context does not contain defined modules.");
+ Preconditions.checkArgument(modules != null,"Sef of Modules cannot be NULL.");
final List<Type> filteredGenTypes = new ArrayList<>();
schemaContext = context;
*
*/
private List<Type> allTypeDefinitionsToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
- if (module.getTypeDefinitions() == null) {
- throw new IllegalArgumentException("Type Definitions for module " + module.getName() + " cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
+ Preconditions.checkArgument(module.getTypeDefinitions() != null,"Type Definitions for module " + module.getName() + " cannot be NULL.");
final Set<TypeDefinition<?>> typeDefinitions = module.getTypeDefinitions();
final List<Type> generatedTypes = new ArrayList<>();
*
*/
private List<Type> allContainersToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()
- + " cannot be NULL!");
+ + " cannot be NULL.");
}
final List<Type> generatedTypes = new ArrayList<>();
*
*/
private List<Type> allListsToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of Child Nodes in module " + module.getName()
- + " cannot be NULL!");
+ + " cannot be NULL.");
}
final List<Type> generatedTypes = new ArrayList<>();
*
*/
private List<GeneratedType> allChoicesToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
final DataNodeIterator it = new DataNodeIterator(module);
final List<ChoiceNode> choiceNodes = it.allChoices();
*
*/
private List<Type> allAugmentsToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of Augmentation Definitions in module "
- + module.getName() + " cannot be NULL!");
+ + module.getName() + " cannot be NULL.");
}
final List<Type> generatedTypes = new ArrayList<>();
*
*/
private List<AugmentationSchema> resolveAugmentations(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
- if (module.getAugmentations() == null) {
- throw new IllegalStateException("Augmentations Set cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
+ Preconditions.checkState(module.getAugmentations() != null,"Augmentations Set cannot be NULL.");
final Set<AugmentationSchema> augmentations = module.getAugmentations();
final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(augmentations);
*
*/
private GeneratedType moduleToDataType(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");
addImplementedInterfaceFromUses(module, moduleDataTypeBuilder);
*
*/
private List<Type> allRPCMethodsToGenType(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of RPC Method Definitions in module "
- + module.getName() + " cannot be NULL!");
+ + module.getName() + " cannot be NULL.");
}
final String basePackageName = moduleNamespaceToPackageName(module);
*
*/
private List<Type> allNotificationsToGenType(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
- if (module.getName() == null) {
- throw new IllegalArgumentException("Module name cannot be NULL!");
- }
+ Preconditions.checkArgument(module.getName() != null,"Module name cannot be NULL.");
if (module.getChildNodes() == null) {
throw new IllegalArgumentException("Reference to Set of Notification Definitions in module "
- + module.getName() + " cannot be NULL!");
+ + module.getName() + " cannot be NULL.");
}
final String basePackageName = moduleNamespaceToPackageName(module);
*
*/
private List<Type> allGroupingsToGenTypes(final Module module) {
- if (module == null) {
- throw new IllegalArgumentException("Module parameter can not be null");
- }
+ Preconditions.checkArgument(module != null,"Module parameter can not be null");
final List<Type> genTypes = new ArrayList<>();
final String basePackageName = moduleNamespaceToPackageName(module);
final Set<GroupingDefinition> groupings = module.getGroupings();
* if <code>module</code> equals null
*/
private GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix) {
- if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
- }
+ Preconditions.checkArgument(module != null,"Module reference cannot be NULL.");
String packageName = moduleNamespaceToPackageName(module);
final String moduleName = parseToClassName(module.getName()) + postfix;
* </ul>
*/
private List<Type> augmentationToGenTypes(final String augmentPackageName, final AugmentationSchema augSchema) {
- if (augmentPackageName == null) {
- throw new IllegalArgumentException("Package Name cannot be NULL!");
- }
- if (augSchema == null) {
- throw new IllegalArgumentException("Augmentation Schema cannot be NULL!");
- }
- if (augSchema.getTargetPath() == null) {
- throw new IllegalStateException("Augmentation Schema does not contain Target Path (Target Path is NULL).");
- }
+ Preconditions.checkArgument(augmentPackageName != null,"Package Name cannot be NULL.");
+ Preconditions.checkArgument(augSchema != null,"Augmentation Schema cannot be NULL.");
+ Preconditions.checkState(augSchema.getTargetPath() != null,"Augmentation Schema does not contain Target Path (Target Path is NULL).");
final List<Type> genTypes = new ArrayList<>();
*/
private void resolveChoiceSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,
final ChoiceNode choiceNode) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
- if (typeBuilder == null) {
- throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
- }
- if (choiceNode == null) {
- throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL.");
+ Preconditions.checkArgument(typeBuilder != null,"Generated Type Builder cannot be NULL.");
+ Preconditions.checkArgument(choiceNode != null,"Choice Schema Node cannot be NULL.");
final String choiceName = choiceNode.getQName().getLocalName();
if (choiceName != null && !choiceNode.isAddedByUses()) {
*
*/
private List<GeneratedType> choiceToGeneratedType(final String basePackageName, final ChoiceNode choiceNode) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
- if (choiceNode == null) {
- throw new IllegalArgumentException("Choice Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL.");
+ Preconditions.checkArgument(choiceNode != null,"Choice Schema Node cannot be NULL.");
final List<GeneratedType> generatedTypes = new ArrayList<>();
final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());
*/
private List<GeneratedType> generateTypesFromChoiceCases(final String basePackageName, final Type refChoiceType,
final Set<ChoiceCaseNode> caseNodes) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
- if (refChoiceType == null) {
- throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");
- }
- if (caseNodes == null) {
- throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL.");
+ Preconditions.checkArgument(refChoiceType != null,"Referenced Choice Type cannot be NULL.");
+ Preconditions.checkArgument(caseNodes != null,"Set of Choice Case Nodes cannot be NULL.");
final List<GeneratedType> generatedTypes = new ArrayList<>();
for (final ChoiceCaseNode caseNode : caseNodes) {
*/
private List<GeneratedType> generateTypesFromAugmentedChoiceCases(final String basePackageName,
final Type refChoiceType, final Set<ChoiceCaseNode> caseNodes) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
- if (refChoiceType == null) {
- throw new IllegalArgumentException("Referenced Choice Type cannot be NULL!");
- }
- if (caseNodes == null) {
- throw new IllegalArgumentException("Set of Choice Case Nodes cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL.");
+ Preconditions.checkArgument(refChoiceType != null,"Referenced Choice Type cannot be NULL.");
+ Preconditions.checkArgument(caseNodes != null,"Set of Choice Case Nodes cannot be NULL.");
final List<GeneratedType> generatedTypes = new ArrayList<>();
for (final ChoiceCaseNode caseNode : caseNodes) {
*/
private GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode,
final String prefix) {
- if (schemaNode == null) {
- throw new IllegalArgumentException("Data Schema Node cannot be NULL!");
- }
- if (packageName == null) {
- throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");
- }
- if (schemaNode.getQName() == null) {
- throw new IllegalArgumentException("QName for Data Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(schemaNode != null,"Data Schema Node cannot be NULL.");
+ Preconditions.checkArgument(packageName != null,"Package Name for Generated Type cannot be NULL.");
+ Preconditions.checkArgument(schemaNode.getQName() != null,"QName for Data Schema Node cannot be NULL.");
final String schemaNodeName = schemaNode.getQName().getLocalName();
- if (schemaNodeName == null) {
- throw new IllegalArgumentException("Local Name of QName for Data Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(schemaNodeName != null,"Local Name of QName for Data Schema Node cannot be NULL.");
final String genTypeName;
if (prefix == null) {
}
private List<Type> listToGenType(final String basePackageName, final ListSchemaNode list) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Package Name for Generated Type cannot be NULL!");
- }
- if (list == null) {
- throw new IllegalArgumentException("List Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Package Name for Generated Type cannot be NULL.");
+ Preconditions.checkArgument(list != null,"List Schema Node cannot be NULL.");
final String packageName = packageNameForGeneratedType(basePackageName, list.getPath());
// final GeneratedTypeBuilder typeBuilder =
*/
private void addSchemaNodeToListBuilders(final String basePackageName, final DataSchemaNode schemaNode,
final GeneratedTypeBuilder typeBuilder, final GeneratedTOBuilder genTOBuilder, final List<String> listKeys) {
- if (schemaNode == null) {
- throw new IllegalArgumentException("Data Schema Node cannot be NULL!");
- }
+ Preconditions.checkArgument(schemaNode != null,"Data Schema Node cannot be NULL.");
- if (typeBuilder == null) {
- throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
- }
+ Preconditions.checkArgument(typeBuilder != null,"Generated Type Builder cannot be NULL.");
if (schemaNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) schemaNode;
private List<Type> typeBuildersToGenTypes(final GeneratedTypeBuilder typeBuilder, GeneratedTOBuilder genTOBuilder) {
final List<Type> genTypes = new ArrayList<>();
- if (typeBuilder == null) {
- throw new IllegalArgumentException("Generated Type Builder cannot be NULL!");
- }
+ Preconditions.checkArgument(typeBuilder != null,"Generated Type Builder cannot be NULL.");
if (genTOBuilder != null) {
final GeneratedTransferObject genTO = genTOBuilder.toInstance();
import org.opendaylight.yangtools.yang.model.util.UnionType;
import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
+import com.google.common.base.Preconditions;
+
public final class TypeProviderImpl implements TypeProvider {
/**
* Contains the schema data red from YANG files.
* if <code>schemaContext</code> equal null.
*/
public TypeProviderImpl(final SchemaContext schemaContext) {
- if (schemaContext == null) {
- throw new IllegalArgumentException("Schema Context cannot be null!");
- }
+ Preconditions.checkArgument(schemaContext != null,"Schema Context cannot be null!");
this.schemaContext = schemaContext;
this.genTypeDefsContextMap = new HashMap<>();
*
*/
public void putReferencedType(final SchemaPath refTypePath, final Type refType) {
- if (refTypePath == null) {
- throw new IllegalArgumentException("Path reference of " + "Enumeration Type Definition cannot be NULL!");
- }
+ Preconditions.checkArgument(refTypePath != null,"Path reference of Enumeration Type Definition cannot be NULL!");
- if (refType == null) {
- throw new IllegalArgumentException("Reference to Enumeration " + "Type cannot be NULL!");
- }
+ Preconditions.checkArgument(refType != null,"Reference to Enumeration Type cannot be NULL!");
referencedTypes.put(refTypePath, refType);
}
@Override
public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition) {
Type returnType = null;
- if (typeDefinition == null) {
- throw new IllegalArgumentException("Type Definition cannot be NULL!");
- }
+ Preconditions.checkArgument(typeDefinition != null,"Type Definition cannot be NULL!");
if (typeDefinition.getQName() == null) {
throw new IllegalArgumentException(
"Type Definition cannot have non specified QName (QName cannot be NULL!)");
}
- if (typeDefinition.getQName().getLocalName() == null) {
- throw new IllegalArgumentException("Type Definitions Local Name cannot be NULL!");
- }
+ Preconditions.checkArgument(typeDefinition.getQName().getLocalName() != null,"Type Definitions Local Name cannot be NULL!");
if (typeDefinition instanceof ExtendedType) {
returnType = javaTypeForExtendedType(typeDefinition);
identity = id;
}
}
- if (identity == null) {
- throw new IllegalArgumentException("Target identity '" + baseIdQName + "' do not exists");
- }
+ Preconditions.checkArgument(identity != null,"Target identity '" + baseIdQName + "' do not exists");
final String basePackageName = moduleNamespaceToPackageName(module);
final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath());
*/
public Type generatedTypeForExtendedDefinitionType(final TypeDefinition<?> typeDefinition) {
Type returnType = null;
- if (typeDefinition == null) {
- throw new IllegalArgumentException("Type Definition cannot be NULL!");
- }
+ Preconditions.checkArgument(typeDefinition != null,"Type Definition cannot be NULL!");
if (typeDefinition.getQName() == null) {
throw new IllegalArgumentException(
"Type Definition cannot have non specified QName (QName cannot be NULL!)");
}
- if (typeDefinition.getQName().getLocalName() == null) {
- throw new IllegalArgumentException("Type Definitions Local Name cannot be NULL!");
- }
+ Preconditions.checkArgument(typeDefinition.getQName().getLocalName() != null,"Type Definitions Local Name cannot be NULL!");
final String typedefName = typeDefinition.getQName().getLocalName();
if (typeDefinition instanceof ExtendedType) {
* if <code>extendTypeDef</code> equal null
*/
private TypeDefinition<?> baseTypeDefForExtendedType(final TypeDefinition<?> extendTypeDef) {
- if (extendTypeDef == null) {
- throw new IllegalArgumentException("Type Definiition reference cannot be NULL!");
- }
+ Preconditions.checkArgument(extendTypeDef != null,"Type Definiition reference cannot be NULL!");
final TypeDefinition<?> baseTypeDef = extendTypeDef.getBaseType();
if (baseTypeDef instanceof ExtendedType) {
return baseTypeDefForExtendedType(baseTypeDef);
*/
public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType) {
Type returnType = null;
- if (leafrefType == null) {
- throw new IllegalArgumentException("Leafref Type Definition reference cannot be NULL!");
- }
+ Preconditions.checkArgument(leafrefType != null,"Leafref Type Definition reference cannot be NULL!");
- if (leafrefType.getPathStatement() == null) {
- throw new IllegalArgumentException("The Path Statement for Leafref Type Definition cannot be NULL!");
- }
+ Preconditions.checkArgument(leafrefType.getPathStatement() != null,"The Path Statement for Leafref Type Definition cannot be NULL!");
final RevisionAwareXPath xpath = leafrefType.getPathStatement();
final String strXPath = xpath.toString();
* </ul>
*/
private Enumeration provideTypeForEnum(final EnumTypeDefinition enumTypeDef, final String enumName) {
- if (enumTypeDef == null) {
- throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
- }
- if (enumTypeDef.getValues() == null) {
- throw new IllegalArgumentException("EnumTypeDefinition MUST contain at least ONE value definition!");
- }
- if (enumTypeDef.getQName() == null) {
- throw new IllegalArgumentException("EnumTypeDefinition MUST contain NON-NULL QName!");
- }
- if (enumTypeDef.getQName().getLocalName() == null) {
- throw new IllegalArgumentException("Local Name in EnumTypeDefinition QName cannot be NULL!");
- }
+ Preconditions.checkArgument(enumTypeDef != null,"EnumTypeDefinition reference cannot be NULL!");
+ Preconditions.checkArgument(enumTypeDef.getValues() != null,"EnumTypeDefinition MUST contain at least ONE value definition!");
+ Preconditions.checkArgument(enumTypeDef.getQName() != null,"EnumTypeDefinition MUST contain NON-NULL QName!");
+ Preconditions.checkArgument(enumTypeDef.getQName().getLocalName() != null,"Local Name in EnumTypeDefinition QName cannot be NULL!");
final String enumerationName = parseToClassName(enumName);
*/
private Enumeration addInnerEnumerationToTypeBuilder(final EnumTypeDefinition enumTypeDef, final String enumName,
final GeneratedTypeBuilder typeBuilder) {
- if (enumTypeDef == null) {
- throw new IllegalArgumentException("EnumTypeDefinition reference cannot be NULL!");
- }
- if (enumTypeDef.getValues() == null) {
- throw new IllegalArgumentException("EnumTypeDefinition MUST contain at least ONE value definition!");
- }
- if (enumTypeDef.getQName() == null) {
- throw new IllegalArgumentException("EnumTypeDefinition MUST contain NON-NULL QName!");
- }
- if (enumTypeDef.getQName().getLocalName() == null) {
- throw new IllegalArgumentException("Local Name in EnumTypeDefinition QName cannot be NULL!");
- }
- if (typeBuilder == null) {
- throw new IllegalArgumentException("Generated Type Builder reference cannot be NULL!");
- }
+ Preconditions.checkArgument(enumTypeDef != null,"EnumTypeDefinition reference cannot be NULL!");
+ Preconditions.checkArgument(enumTypeDef.getValues() != null,"EnumTypeDefinition MUST contain at least ONE value definition!");
+ Preconditions.checkArgument(enumTypeDef.getQName() != null,"EnumTypeDefinition MUST contain NON-NULL QName!");
+ Preconditions.checkArgument(enumTypeDef.getQName().getLocalName() != null,"Local Name in EnumTypeDefinition QName cannot be NULL!");
+ Preconditions.checkArgument(typeBuilder != null,"Generated Type Builder reference cannot be NULL!");
final String enumerationName = parseToClassName(enumName);
*/
private void resolveTypeDefsFromContext() {
final Set<Module> modules = schemaContext.getModules();
- if (modules == null) {
- throw new IllegalArgumentException("Sef of Modules cannot be NULL!");
- }
+ Preconditions.checkArgument(modules != null,"Sef of Modules cannot be NULL!");
final Module[] modulesArray = new Module[modules.size()];
int i = 0;
for (Module modul : modules) {
*/
public List<GeneratedTOBuilder> provideGeneratedTOBuildersForUnionTypeDef(final String basePackageName,
final TypeDefinition<?> typedef, final String typeDefName) {
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
- if (typedef == null) {
- throw new IllegalArgumentException("Type Definition cannot be NULL!");
- }
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL!");
+ Preconditions.checkArgument(typedef != null,"Type Definition cannot be NULL!");
if (typedef.getQName() == null) {
throw new IllegalArgumentException(
"Type Definition cannot have non specified QName (QName cannot be NULL!)");
public GeneratedTOBuilder provideGeneratedTOBuilderForBitsTypeDefinition(final String basePackageName,
final TypeDefinition<?> typeDef, String typeDefName) {
- if (typeDef == null) {
- throw new IllegalArgumentException("typeDef cannot be NULL!");
- }
- if (basePackageName == null) {
- throw new IllegalArgumentException("Base Package Name cannot be NULL!");
- }
+ Preconditions.checkArgument(typeDef != null,"typeDef cannot be NULL!");
+ Preconditions.checkArgument(basePackageName != null,"Base Package Name cannot be NULL!");
if (typeDef instanceof BitsTypeDefinition) {
BitsTypeDefinition bitsTypeDefinition = (BitsTypeDefinition) typeDef;
*/
private List<String> resolveRegExpressionsFromTypedef(ExtendedType typedef) {
final List<String> regExps = new ArrayList<String>();
- if (typedef == null) {
- throw new IllegalArgumentException("typedef can't be null");
- }
+ Preconditions.checkArgument(typedef != null,"typedef can't be null");
final TypeDefinition<?> strTypeDef = baseTypeDefForExtendedType(typedef);
if (strTypeDef instanceof StringType) {
final List<PatternConstraint> patternConstraints = typedef.getPatterns();
private GeneratedTransferObject provideGeneratedTOFromExtendedType(final ExtendedType innerExtendedType,
final String basePackageName, final String typedefName) {
- if (innerExtendedType == null) {
- throw new IllegalArgumentException("Extended type cannot be NULL!");
- }
- if (basePackageName == null) {
- throw new IllegalArgumentException("String with base package name cannot be NULL!");
- }
- if (typedefName == null) {
- throw new IllegalArgumentException("String with type definition name cannot be NULL!");
- }
+ Preconditions.checkArgument(innerExtendedType != null,"Extended type cannot be NULL!");
+ Preconditions.checkArgument(basePackageName != null,"String with base package name cannot be NULL!");
+ Preconditions.checkArgument(typedefName != null,"String with type definition name cannot be NULL!");
final String classTypedefName = parseToClassName(typedefName);
final String innerTypeDef = innerExtendedType.getQName().getLocalName();
* definition to the base type
*/
private int getTypeDefinitionDepth(final TypeDefinition<?> typeDefinition) {
- if (typeDefinition == null) {
- throw new IllegalArgumentException("Type definition can't be null");
- }
+ Preconditions.checkArgument(typeDefinition != null,"Type definition can't be null");
int depth = 1;
TypeDefinition<?> baseType = typeDefinition.getBaseType();