* @throws IllegalArgumentException If supplied class is not an augmentation or current context does not contain schema for augmentation.
*/
public AugmentationSchema getAugmentationDefinition(final Class<?> augClass) throws IllegalArgumentException {
- Preconditions.checkArgument(Augmentation.class.isAssignableFrom(augClass), "Class {} does not represent augmentation", augClass);
+ Preconditions.checkArgument(Augmentation.class.isAssignableFrom(augClass), "Class %s does not represent augmentation", augClass);
final AugmentationSchema ret = augmentationToSchema.get(referencedType(augClass));
- Preconditions.checkArgument(ret != null, "Supplied augmentation {} is not valid in current context", augClass);
+ Preconditions.checkArgument(ret != null, "Supplied augmentation %s is not valid in current context", augClass);
return ret;
}
* @return Schema node, from which class was generated.
*/
public DataSchemaNode getSchemaDefinition(final Class<?> cls) {
- Preconditions.checkArgument(!Augmentation.class.isAssignableFrom(cls),"Supplied class must not be augmentation");
+ Preconditions.checkArgument(!Augmentation.class.isAssignableFrom(cls),"Supplied class must not be augmentation (%s is)", cls);
return (DataSchemaNode) typeToDefiningSchema.get(referencedType(cls));
}
*
* @param schema Resolved parent choice schema
* @param childClass Class representing case.
- * @return Resolved case schema.
- * @throws IllegalArgumentException If supplied class does not represent case or supplied case class is not
- * valid in the context of parent choice schema.
+ * @return Optionally a resolved case schema, absent if the choice is not legal in
+ * the given context.
+ * @throws IllegalArgumentException If supplied class does not represent case.
*/
- public ChoiceCaseNode getCaseSchemaDefinition(final ChoiceNode schema, final Class<?> childClass) throws IllegalArgumentException {
+ public Optional<ChoiceCaseNode> getCaseSchemaDefinition(final ChoiceNode schema, final Class<?> childClass) throws IllegalArgumentException {
DataSchemaNode origSchema = getSchemaDefinition(childClass);
- Preconditions.checkArgument(origSchema instanceof ChoiceCaseNode, "Supplied {} is not case.");
+ Preconditions.checkArgument(origSchema instanceof ChoiceCaseNode, "Supplied schema %s is not case.", origSchema);
+
/* FIXME: Make sure that if there are multiple augmentations of same
* named case, with same structure we treat it as equals
* this is due property of Binding specification and copy builders
* that user may be unaware that he is using incorrect case
* which was generated for choice inside grouping.
*/
- Optional<ChoiceCaseNode> found = BindingSchemaContextUtils.findInstantiatedCase(schema,
+ final Optional<ChoiceCaseNode> found = BindingSchemaContextUtils.findInstantiatedCase(schema,
(ChoiceCaseNode) origSchema);
- Preconditions.checkArgument(found.isPresent(), "Supplied {} is not valid case in schema", schema);
- return found.get();
+ return found;
}
private static Type referencedType(final Class<?> type) {
public Class<?> getIdentityClass(final QName input) {
Type identityType = identities.get(input);
- Preconditions.checkArgument(identityType != null, "Supplied QName is not valid identity");
+ Preconditions.checkArgument(identityType != null, "Supplied QName %s is not a valid identity", input);
try {
return strategy.loadClass(identityType);
} catch (ClassNotFoundException e) {