Class AcceptanceCondition
- java.lang.Object
-
- net.sf.tweety.arg.adf.syntax.AcceptanceCondition
-
- Direct Known Subclasses:
Argument
,AssociativeAcceptanceCondition
,BinaryAcceptanceCondition
,ContradictionAcceptanceCondition
,TautologyAcceptanceCondition
,UnaryAcceptanceCondition
public abstract class AcceptanceCondition extends java.lang.Object
An immutable representation of acceptance conditions for ADFs.Mirrors the structure of
PlFormula
.- Author:
- Mathias Hofer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AcceptanceCondition.Builder
-
Constructor Summary
Constructors Constructor Description AcceptanceCondition()
-
Method Summary
Modifier and Type Method Description abstract java.util.stream.Stream<Argument>
arguments()
AcceptanceCondition.Builder
builder()
static AcceptanceCondition.Builder
builder(AcceptanceCondition acc)
<C,R,O>
Rcollect(Transform<C,R> transform, java.util.function.BiConsumer<O,C> accumulator, O container)
Similar tocollect(Transform, Collector)
but with the main difference that it allows us access to all returned values of the given transform.<C,R,A,O>
Ocollect(Transform<C,R> transform, java.util.stream.Collector<C,A,O> collector)
A powerful method which allows us to collect arbitrary information provided by the given transform into arbitrary data-structures provided by the collector.protected abstract java.lang.String
getName()
boolean
isContradiction()
Note that this method does not perform any computations to determine if this acceptance condition is a tautology, it only checks if this is of typeContradictionAcceptanceCondition
.boolean
isTautology()
Note that this method does not perform any computations to determine if this acceptance condition is a tautology, it only checks if this is of typeTautologyAcceptanceCondition
.java.lang.String
toString()
<R> R
transform(Transform<?,R> transform)
A simple transform operation which is expected to be used in cases where we just want to transform this recursive structure into another recursive structure.protected abstract <C,R>
Rtransform(Transform<C,R> transform, java.util.function.Consumer<C> consumer, int polarity)
-
-
-
Method Detail
-
arguments
public abstract java.util.stream.Stream<Argument> arguments()
- Returns:
- a stream of all arguments of this acceptance condition and its subconditions.
-
collect
public <C,R,A,O> O collect(Transform<C,R> transform, java.util.stream.Collector<C,A,O> collector)
A powerful method which allows us to collect arbitrary information provided by the given transform into arbitrary data-structures provided by the collector.The information we collect is defined by the generic type C of the transform and is retrieved via a
Consumer
the transform implementation can use in order to write out further return values besides the one of its second generic type R. Which means that we can only collect values if the givenTransform
returns values via its consumer. This is not necessarily the case, since for simple transform operations, like the transform fromAcceptanceCondition
toPlFormula
, there is no need for additional return values, since its just a 1:1 mapping of its structure. In cases likeDefinitionalCNFTransform
such a 1:1 mapping is not the case however, in this case the consumer is used to return the generated clauses which we can then collect.- Type Parameters:
C
- the type we want to collect during the transform process, e.g. the type of the generated clauses in the case of a CNF-transformR
- the return type of each transform step, or in other words the type of the information we pass from the bottom to the top of the structureA
- the mutable accumulation type of the reduction operation (seeCollector
)O
- the result type of the accumulation operation (seeCollector
)- Parameters:
transform
- the transform operationcollector
- the collector which is used for collecting the information we get during the transform operation- Returns:
- the collected transformed structure
-
collect
public <C,R,O> R collect(Transform<C,R> transform, java.util.function.BiConsumer<O,C> accumulator, O container)
Similar tocollect(Transform, Collector)
but with the main difference that it allows us access to all returned values of the given transform. Hence, the C values given to us via theConsumer
parameter of the transform methods inTransform
and the directly returned bottom-up information.Instead of an encapsulating
Collector
this method expects an already initialized container of type O and aBiConsumer
which works as an abstraction to the add method of the container. This abstraction is needed since the container can be completely arbitrary.- Type Parameters:
C
- the type we want to collect during the transform process, e.g. the type of the generated clauses in the case of a CNF-transformR
- the return type of each transform step, or in other words the type of the information we pass from the bottom to the top of the structureO
- the result type of the accumulation operation (seeCollector
)- Parameters:
transform
- the transform operationaccumulator
-container
-- Returns:
- the result of the transformed root acceptance condition
-
isTautology
public boolean isTautology()
Note that this method does not perform any computations to determine if this acceptance condition is a tautology, it only checks if this is of typeTautologyAcceptanceCondition
.This is useful for some syntax level rewriting to avoid instanceof checks and keep the code typesafe.
- Returns:
- true iff this acceptance condition represents the tautology constant
-
isContradiction
public boolean isContradiction()
Note that this method does not perform any computations to determine if this acceptance condition is a tautology, it only checks if this is of typeContradictionAcceptanceCondition
.This is useful for some syntax level rewriting to avoid instanceof checks and keep the code typesafe.
- Returns:
- true iff this acceptance condition represents the contradiction constant
-
getName
protected abstract java.lang.String getName()
-
transform
protected abstract <C,R> R transform(Transform<C,R> transform, java.util.function.Consumer<C> consumer, int polarity)
-
transform
public <R> R transform(Transform<?,R> transform)
A simple transform operation which is expected to be used in cases where we just want to transform this recursive structure into another recursive structure. No additional return values provided by the given transform is used.More generally speaking, it can be used whenever we are only interested in the result of the transformation of the root acceptance condition. Which is usually the case for recursive structures, since they have a reference to their sub-structures.
- Type Parameters:
R
- the return type of each transform step, or in other words the type of the information we pass from the bottom to the top of the structure- Parameters:
transform
- the transform operation- Returns:
- the result of the (simple) recursive transform operation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
builder
public AcceptanceCondition.Builder builder()
-
builder
public static AcceptanceCondition.Builder builder(AcceptanceCondition acc)
-
-