Java Code Examples for com.mojang.datafixers.types.Type#FieldNotFoundException
The following examples show how to use
com.mojang.datafixers.types.Type#FieldNotFoundException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tag.java From DataFixerUpper with MIT License | 5 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { if (!Objects.equals(name, this.name)) { return Either.right(new Type.FieldNotFoundException("Names don't match")); } if (element instanceof Const) { final Const c = (Const) element; if (Objects.equals(type, c.type())) { return Either.left(new Tag(name, new Const(resultType))); } return Either.right(new Type.FieldNotFoundException("don't match")); } // safe to return the same template if (Objects.equals(type, resultType)) { return Either.left(this); } if (type instanceof RecursivePoint.RecursivePointType<?> && element instanceof RecursivePoint) { if (((RecursivePoint) element).index() == ((RecursivePoint.RecursivePointType<?>) type).index()) { if (resultType instanceof RecursivePoint.RecursivePointType<?>) { if (((RecursivePoint.RecursivePointType<?>) resultType).index() == ((RecursivePoint) element).index()) { return Either.left(this); } } else { return Either.left(DSL.constType(resultType)); } } } return Either.right(new Type.FieldNotFoundException("Recursive field")); }
Example 2
Source File: NamedChoiceFinder.java From DataFixerUpper with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override public <S> Either<TypedOptic<S, ?, FT, FR>, Type.FieldNotFoundException> match(final Type<S> targetType) { /*if (targetType instanceof Type.NamedType<?>) { final Type.NamedType<?> namedType = (Type.NamedType<?>) targetType; if (!Objects.equals(namedType.name, name)) { return Either.right(new Type.FieldNotFoundException(String.format("Not found: \"%s\" (type: %s)", name, targetType))); } if (!Objects.equals(type, namedType.element)) { return Either.right(new Type.FieldNotFoundException(String.format("Type error for named type \"%s\": expected type: %s, actual type: %s)", name, targetType, namedType.element))); } return Either.left((Type.TypedOptic<S, ?, FT, FR>) cap(namedType)); }*/ if (targetType instanceof TaggedChoice.TaggedChoiceType<?>) { final TaggedChoice.TaggedChoiceType<?> choiceType = (TaggedChoice.TaggedChoiceType<?>) targetType; final Type<?> elementType = choiceType.types().get(name); if (elementType != null) { if (!Objects.equals(type, elementType)) { return Either.right(new Type.FieldNotFoundException(String.format("Type error for choice type \"%s\": expected type: %s, actual type: %s)", name, targetType, elementType))); } return Either.left((TypedOptic<S, ?, FT, FR>) tagged((TaggedChoice.TaggedChoiceType<String>) choiceType, name, type, resultType)); } return Either.right(new Type.Continue()); } if (targetType instanceof Tag.TagType<?>) { return Either.right(new Type.FieldNotFoundException("in tag")); } return Either.right(new Type.Continue()); }
Example 3
Source File: Product.java From DataFixerUpper with MIT License | 5 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { final Either<TypeTemplate, Type.FieldNotFoundException> either = f.findFieldOrType(index, name, type, resultType); return either.map( f2 -> Either.left(new Product(f2, g)), r -> g.findFieldOrType(index, name, type, resultType).mapLeft(g2 -> new Product(f, g2)) ); }
Example 4
Source File: Check.java From DataFixerUpper with MIT License | 5 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { if (index == this.index) { return element.findFieldOrType(index, name, type, resultType); } return Either.right(new Type.FieldNotFoundException("Not a matching index")); }
Example 5
Source File: Sum.java From DataFixerUpper with MIT License | 5 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { final Either<TypeTemplate, Type.FieldNotFoundException> either = f.findFieldOrType(index, name, type, resultType); return either.map( f2 -> Either.left(new Sum(f2, g)), r -> g.findFieldOrType(index, name, type, resultType).mapLeft(g2 -> new Sum(f, g2)) ); }
Example 6
Source File: RecursivePoint.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return Either.right(new Type.FieldNotFoundException("Recursion point")); }
Example 7
Source File: CompoundList.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return element.findFieldOrType(index, name, type, resultType).mapLeft(element1 -> new CompoundList(key, element1)); }
Example 8
Source File: List.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return element.findFieldOrType(index, name, type, resultType).mapLeft(List::new); }
Example 9
Source File: FieldFinder.java From DataFixerUpper with MIT License | 4 votes |
@Override public <A, FR> Either<TypedOptic<A, ?, FT, FR>, Type.FieldNotFoundException> findType(final Type<A> containerType, final Type<FR> resultType, final boolean recurse) { return containerType.findTypeCached(type, resultType, new Matcher<>(name, type, resultType), recurse); }
Example 10
Source File: Const.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return DSL.fieldFinder(name, type).findType(this.type, resultType, false).mapLeft(field -> new Const(field.tType())); }
Example 11
Source File: Hook.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return element.findFieldOrType(index, name, type, resultType); }
Example 12
Source File: Named.java From DataFixerUpper with MIT License | 4 votes |
@Override public <FT, FR> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<FT> type, final Type<FR> resultType) { return element.findFieldOrType(index, name, type, resultType); }
Example 13
Source File: TaggedChoice.java From DataFixerUpper with MIT License | 4 votes |
@Override public <A, B> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable final String name, final Type<A> type, final Type<B> resultType) { return Either.right(new Type.FieldNotFoundException("Not implemented")); }
Example 14
Source File: RecursiveTypeFamily.java From DataFixerUpper with MIT License | 4 votes |
private <S, T, A, B> Either<TypedOptic<?, ?, A, B>, Type.FieldNotFoundException> mkSimpleOptic(final RecursivePoint.RecursivePointType<S> sType, final RecursivePoint.RecursivePointType<T> tType, final Type<A> aType, final Type<B> bType, final Type.TypeMatcher<A, B> matcher) { return sType.unfold().findType(aType, bType, matcher, false).mapLeft(o -> mkOptic(sType, tType, o.aType(), o.bType(), new OpticParts<>(o.bounds(), o.optic()))); }
Example 15
Source File: OpticFinder.java From DataFixerUpper with MIT License | 4 votes |
default <A> Either<TypedOptic<A, ?, FT, FT>, Type.FieldNotFoundException> findType(final Type<A> containerType, final boolean recurse) { return findType(containerType, type(), recurse); }
Example 16
Source File: NamedChoiceFinder.java From DataFixerUpper with MIT License | 4 votes |
@Override public <A, FR> Either<TypedOptic<A, ?, FT, FR>, Type.FieldNotFoundException> findType(final Type<A> containerType, final Type<FR> resultType, final boolean recurse) { return containerType.findTypeCached(type, resultType, new Matcher<>(name, type, resultType), recurse); }
Example 17
Source File: FieldFinder.java From DataFixerUpper with MIT License | 4 votes |
@SuppressWarnings("unchecked") @Override public <S> Either<TypedOptic<S, ?, FT, FR>, Type.FieldNotFoundException> match(final Type<S> targetType) { if (name == null && type.equals(targetType, true, false)) { return Either.left((TypedOptic<S, FR, FT, FR>) new TypedOptic<>( Profunctor.Mu.TYPE_TOKEN, targetType, resultType, targetType, resultType, Optics.id() )); } if (targetType instanceof Tag.TagType<?>) { final Tag.TagType<S> tagType = (Tag.TagType<S>) targetType; if (!Objects.equals(tagType.name(), name)) { return Either.right(new Type.FieldNotFoundException(String.format("Not found: \"%s\" (in type: %s)", name, targetType))); } if (!Objects.equals(type, tagType.element())) { return Either.right(new Type.FieldNotFoundException(String.format("Type error for field \"%s\": expected type: %s, actual type: %s)", name, type, tagType.element()))); } return Either.left(new TypedOptic<>( Profunctor.Mu.TYPE_TOKEN, tagType, DSL.field(tagType.name(), resultType), type, resultType, (Adapter<S, FR, FT, FR>) Optics.id() )); } if (targetType instanceof TaggedChoice.TaggedChoiceType<?>) { final TaggedChoice.TaggedChoiceType<FT> choiceType = (TaggedChoice.TaggedChoiceType<FT>) targetType; if (Objects.equals(name, choiceType.getName())) { if (!Objects.equals(type, choiceType.getKeyType())) { return Either.right(new Type.FieldNotFoundException(String.format("Type error for field \"%s\": expected type: %s, actual type: %s)", name, type, choiceType.getKeyType()))); } if (!Objects.equals(type, resultType)) { return Either.right(new Type.FieldNotFoundException("TaggedChoiceType key type change is unsupported.")); } return Either.left((TypedOptic<S, ?, FT, FR>) capChoice(choiceType)); } } return Either.right(new Type.Continue()); }
Example 18
Source File: TypeTemplate.java From DataFixerUpper with MIT License | 2 votes |
/** * returned optic will accept template<family<index>> with the input template, and will return the same with the returned template * (template, optic) = Left(result) * this.apply(family).apply(index) == optic.sType * template.apply(family).apply(index) == optic.tType */ <A, B> Either<TypeTemplate, Type.FieldNotFoundException> findFieldOrType(final int index, @Nullable String name, Type<A> type, Type<B> resultType);
Example 19
Source File: OpticFinder.java From DataFixerUpper with MIT License | votes |
<A, FR> Either<TypedOptic<A, ?, FT, FR>, Type.FieldNotFoundException> findType(final Type<A> containerType, final Type<FR> resultType, final boolean recurse);