forked from moditect/deptective
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moditect#27 Adding ComponentReference to represent components on the …
…"to" side of dependencies
- Loading branch information
1 parent
1279dc7
commit c73af1b
Showing
8 changed files
with
114 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
javac-plugin/src/main/java/org/moditect/deptective/internal/model/ComponentReference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* 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 org.moditect.deptective.internal.model; | ||
|
||
import org.moditect.deptective.internal.graph.Dependency; | ||
|
||
/** | ||
* A reference to a component. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public class ComponentReference extends IdentifiableComponent { | ||
|
||
public ComponentReference(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
public Dependency<IdentifiableComponent> getOutgoingDependencyTo(IdentifiableComponent node) { | ||
throw new UnsupportedOperationException("No outgoing dependencies from reference"); | ||
} | ||
|
||
@Override | ||
public boolean hasOutgoingDependencies() { | ||
return false; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
javac-plugin/src/main/java/org/moditect/deptective/internal/model/IdentifiableComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2019 The ModiTect authors | ||
* | ||
* 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 org.moditect.deptective.internal.model; | ||
|
||
import org.moditect.deptective.internal.graph.Node; | ||
|
||
/** | ||
* A component in a software system, e.g. a package or a group of packages. | ||
* <p> | ||
* Identity and equality are solely based on the component's name. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public abstract class IdentifiableComponent implements Node<IdentifiableComponent> { | ||
|
||
protected final String name; | ||
|
||
public IdentifiableComponent(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public final int hashCode() { | ||
return name.hashCode(); | ||
} | ||
|
||
@Override | ||
public final boolean equals(Object other) { | ||
if (other instanceof IdentifiableComponent) { | ||
return name.equals(((IdentifiableComponent) other).name); | ||
} | ||
|
||
return false; | ||
} | ||
} |