View Javadoc
1   package net.bmahe.genetics4j.neat;
2   
3   import org.apache.commons.lang3.Validate;
4   import org.immutables.value.Value;
5   
6   @Value.Immutable
7   public interface Connection {
8   
9   	@Value.Parameter
10  	int fromNodeIndex();
11  
12  	@Value.Parameter
13  	int toNodeIndex();
14  
15  	@Value.Parameter
16  	float weight();
17  
18  	@Value.Parameter
19  	boolean isEnabled();
20  
21  	@Value.Parameter
22  	int innovation();
23  
24  	@Value.Check
25  	default void check() {
26  		Validate.isTrue(fromNodeIndex() >= 0);
27  		Validate.isTrue(toNodeIndex() >= 0);
28  		Validate.isTrue(innovation() >= 0);
29  	}
30  
31  	static class Builder extends ImmutableConnection.Builder {
32  	}
33  
34  	static Builder builder() {
35  		return new Builder();
36  	}
37  
38  	static Connection of(final int from, final int to, final float weight, final boolean isEnabled,
39  			final int innovation) {
40  		return ImmutableConnection.of(from, to, weight, isEnabled, innovation);
41  	}
42  
43  	static Connection copyOf(Connection original) {
44  		return ImmutableConnection.copyOf(original);
45  	}
46  }