Skip to content

Label-node for å kunne navngi trær #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/no/nav/fpsak/nare/evaluation/Operator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum Operator {

AND, OR, SINGLE, NOT, COND_OR, SEQUENCE, COMPUTATIONAL_IF
AND, OR, SINGLE, NOT, COND_OR, SEQUENCE, COMPUTATIONAL_IF, LABEL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package no.nav.fpsak.nare.specification;

import no.nav.fpsak.nare.doc.RuleDescription;
import no.nav.fpsak.nare.evaluation.Evaluation;
import no.nav.fpsak.nare.evaluation.Operator;

/**
* NOT decorator, used to create a new specifcation that is the inverse (IKKE) of the given spec.
*/
public class LabelSpecification<T> extends AbstractSpecification<T> {

public static <V> LabelSpecification<V> label(final Specification<V> spec1, String label) {
return new LabelSpecification<V>(spec1, label);
}

private Specification<T> spec1;
private String label;

public LabelSpecification(final Specification<T> spec1, String label) {
this(spec1, null, label);
}

public LabelSpecification(final Specification<T> spec1, String id, String label) {
super(id);
this.spec1 = spec1;
this.label = label;
}

@Override
public String beskrivelse() {
return label;
}

@Override
public Evaluation evaluate(final T t) {
return spec1.evaluate(t);
}

@Override
public String identifikator() {
return identifikatorIkkeTom().orElseGet(() -> "(" + spec1.identifikator() + ")");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skulle du hatt med label i orElseGet "(" + label + " " + spec1.identifikator() ?

}

@Override
public RuleDescription ruleDescription() {
return new SpecificationRuleDescription(Operator.LABEL, identifikator(), beskrivelse(), spec1.ruleDescription());
}

}