hydra.strip.Strip Maven / Gradle / Ivy
package hydra.strip;
/**
* Several functions for stripping annotations from types and terms.
*/
public interface Strip {
static java.util.function.Function skipAnnotations(java.util.function.Function>> getAnn) {
return (java.util.function.Function) (t -> {
java.util.concurrent.atomic.AtomicReference> skip = new java.util.concurrent.atomic.AtomicReference<>();
skip.set((java.util.function.Function) (t1 -> ((((getAnn)).apply((t1))).map((java.util.function.Function, X>) (ann -> (skip.get()).apply(((ann)).subject)))).orElse((t1))));
return ((skip)).get().apply((t));
});
}
static hydra.core.Term stripTerm(hydra.core.Term x) {
return (hydra.strip.Strip.skipAnnotations((java.util.function.Function, java.util.Optional, A>>>) (v1 -> ((v1)).accept(new hydra.core.Term.PartialVisitor, A>>>() {
@Override
public java.util.Optional, A>> otherwise(hydra.core.Term instance) {
return java.util.Optional.empty();
}
@Override
public java.util.Optional, A>> visit(hydra.core.Term.Annotated instance) {
return java.util.Optional.of((instance.value));
}
})))).apply((x));
}
static hydra.core.Type stripType(hydra.core.Type x) {
return (hydra.strip.Strip.skipAnnotations((java.util.function.Function, java.util.Optional, A>>>) (v1 -> ((v1)).accept(new hydra.core.Type.PartialVisitor, A>>>() {
@Override
public java.util.Optional, A>> otherwise(hydra.core.Type instance) {
return java.util.Optional.empty();
}
@Override
public java.util.Optional, A>> visit(hydra.core.Type.Annotated instance) {
return java.util.Optional.of((instance.value));
}
})))).apply((x));
}
static hydra.core.Type stripTypeParameters(hydra.core.Type t) {
return (hydra.strip.Strip.stripType((t))).accept(new hydra.core.Type.PartialVisitor>() {
@Override
public hydra.core.Type otherwise(hydra.core.Type instance) {
return (t);
}
@Override
public hydra.core.Type visit(hydra.core.Type.Lambda instance) {
return hydra.strip.Strip.stripTypeParameters(((instance.value)).body);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy