BinaryTypeEffectiveStatementImpl( final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx, final BinaryTypeDefinition baseType) { super(ctx); final LengthRestrictedTypeBuilder<BinaryTypeDefinition> builder = RestrictedTypes.newBinaryBuilder(baseType, AbstractTypeStatementSupport.typeEffectiveSchemaPath(ctx)); for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) { if (stmt instanceof LengthEffectiveStatementImpl) { final LengthEffectiveStatementImpl length = (LengthEffectiveStatementImpl)stmt; try { builder.setLengthConstraint(length, length.argument()); } catch (IllegalStateException e) { throw new SourceException(ctx.getStatementSourceReference(), e, "Multiple length constraints encountered"); } catch (InvalidLengthConstraintException e) { throw new SourceException(ctx.getStatementSourceReference(), e, "Invalid length constraint %s", length.argument()); } } if (stmt instanceof UnknownSchemaNode) { builder.addUnknownSchemaNode((UnknownSchemaNode)stmt); } } typeDefinition = builder.build(); }