/** * Gets the {@link FieldType} of the field, if at all available. * * @return The type, wrapped in an {@link Optional} * @since 0.4.0 */ default Optional<FieldType> getType() { // First check the signature if (this.getSignature().getType().isPresent()) return this.getSignature().getType(); // Check the FieldTypeProvider return this.getMappings().getFieldTypeProvider().provide(this); }
@Override public Optional<FieldMapping> computeFieldMapping(FieldSignature signature) { // If the field type is not provided, lookup up only the field name if (!signature.getType().isPresent()) { return this.getFieldMapping(signature.getName()); } // Otherwise, look up the signature as-is, but attempt falling back to a signature without type // Note: We cannot use fieldsByName here, because we'd eventually return FieldMappings with the wrong type return Optional.ofNullable(this.fields.computeIfAbsent(signature, (sig) -> { final FieldMapping mapping = this.fields.get(new FieldSignature(sig.getName())); return mapping != null ? this.getMappings().getModelFactory().createFieldMapping(mapping.getParent(), sig, mapping.getDeobfuscatedName()) : null; })); }