- /**
- * Create new ExtendedType based on given type and with schema path.
- *
- * @param newPath
- * schema path for new type
- * @param oldType
- * type based
- * @return
- */
- static ExtendedType createNewExtendedType(final ExtendedType oldType, final SchemaPath newPath) {
- QName qname = oldType.getQName();
- TypeDefinition<?> newBaseType = ParserUtils.createCorrectTypeDefinition(newPath, oldType.getBaseType());
- String desc = oldType.getDescription();
- String ref = oldType.getReference();
- ExtendedType.Builder builder = new ExtendedType.Builder(qname, newBaseType, desc, ref, newPath);
- builder.status(oldType.getStatus());
- builder.lengths(oldType.getLengths());
- builder.patterns(oldType.getPatterns());
- builder.ranges(oldType.getRanges());
- builder.fractionDigits(oldType.getFractionDigits());
- builder.unknownSchemaNodes(oldType.getUnknownSchemaNodes());
- return builder.build();
- }
-
- static IntegerTypeDefinition createNewIntType(final SchemaPath newSchemaPath,
- final IntegerTypeDefinition type) {
- final String localName = type.getQName().getLocalName();
- if ("int8".equals(localName)) {
- return new Int8(newSchemaPath);
- } else if ("int16".equals(localName)) {
- return new Int16(newSchemaPath);
- } else if ("int32".equals(localName)) {
- return new Int32(newSchemaPath);
- } else if ("int64".equals(localName)) {
- return new Int64(newSchemaPath);
- } else {
- return null;
- }
- }
-
- static UnsignedIntegerTypeDefinition createNewUintType(final SchemaPath newSchemaPath,
- final UnsignedIntegerTypeDefinition type) {
- final String localName = type.getQName().getLocalName();
- if ("uint8".equals(localName)) {
- return new Uint8(newSchemaPath);
- } else if ("uint16".equals(localName)) {
- return new Uint16(newSchemaPath);
- } else if ("uint32".equals(localName)) {
- return new Uint32(newSchemaPath);
- } else if ("uint64".equals(localName)) {
- return new Uint64(newSchemaPath);
- } else {
- return null;
- }
- }
-