All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.emm035.openapi.immutables.v3.references.Referenceable Maven / Gradle / Ivy

package io.github.emm035.openapi.immutables.v3.references;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;

@JsonDeserialize(using = ReferenceableDeserializer.class)
public interface Referenceable> {
  @JsonIgnore
  @Value.Derived
  default boolean isReferential() {
    return false;
  }

  default T asType(Class clazz) {
    if (isReferential() && clazz.isAssignableFrom(this.getClass())) {
      return clazz.cast(this);
    }
    throw new IllegalStateException("Unable to cast " + getClass().getSimpleName() + " to " + clazz.getSimpleName());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy