forked from daanvdh/JavaDataFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataFlowEdge.java
More file actions
100 lines (83 loc) · 2.28 KB
/
DataFlowEdge.java
File metadata and controls
100 lines (83 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright 2018 by Daan van den Heuvel.
*
* This file is part of JavaDataFlow.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package model;
/**
* An edge inside a {@link DataFlowGraph} representing a {@link DataFlowNode} influencing the state of another {@link DataFlowNode}.
*
* @author Daan
*/
public class DataFlowEdge {
private DataFlowNode from;
private DataFlowNode to;
public DataFlowEdge() {
// empty constructor which would otherwise be invisible due to the constructor receiving the builder.
}
private DataFlowEdge(Builder builder) {
this.from = builder.from == null ? this.from : builder.from;
this.to = builder.to == null ? this.to : builder.to;
}
public DataFlowEdge(DataFlowNode from, DataFlowNode to) {
this.from = from;
this.to = to;
}
public DataFlowNode getFrom() {
return from;
}
public void setFrom(DataFlowNode from) {
this.from = from;
}
public DataFlowNode getTo() {
return to;
}
public void setTo(DataFlowNode to) {
this.to = to;
}
@Override
public String toString() {
return from.getName() + "->" + to.getName();
}
/**
* Creates builder to build {@link DataFlowEdge}.
*
* @return created builder
*/
public static Builder builder() {
return new Builder();
}
/**
* Builder to build {@link DataFlowEdge}.
*/
public static final class Builder {
private DataFlowNode from;
private DataFlowNode to;
private Builder() {
// Builder should only be constructed via the parent class
}
public Builder from(DataFlowNode from) {
this.from = from;
return this;
}
public Builder to(DataFlowNode to) {
this.to = to;
return this;
}
public DataFlowEdge build() {
return new DataFlowEdge(this);
}
}
}