-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made some API collection return types more specific, since it integra…
…tes nicer with JDK >= 8 streams. Also introduced ArchUnit's own ForwardingCollection/-Set, since we don't want to have Guava in the public API (sneakily leaked through Slice). Signed-off-by: Peter Gafert <[email protected]>
- Loading branch information
1 parent
69909eb
commit 4a6e738
Showing
31 changed files
with
447 additions
and
29 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
125 changes: 125 additions & 0 deletions
125
archunit/src/main/java/com/tngtech/archunit/base/ForwardingCollection.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,125 @@ | ||
/* | ||
* Copyright 2019 TNG Technology Consulting GmbH | ||
* | ||
* 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 com.tngtech.archunit.base; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
|
||
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS; | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public abstract class ForwardingCollection<T> implements Collection<T> { | ||
protected ForwardingCollection() { | ||
} | ||
|
||
protected abstract Collection<T> delegate(); | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public int size() { | ||
return delegate().size(); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean isEmpty() { | ||
return delegate().isEmpty(); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean contains(Object o) { | ||
return delegate().contains(o); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public Iterator<T> iterator() { | ||
return delegate().iterator(); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public Object[] toArray() { | ||
return delegate().toArray(); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
@SuppressWarnings("SuspiciousToArrayCall") | ||
public <T1> T1[] toArray(T1[] a) { | ||
return delegate().toArray(a); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean add(T t) { | ||
return delegate().add(t); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean remove(Object o) { | ||
return delegate().remove(o); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean containsAll(Collection<?> c) { | ||
return delegate().containsAll(c); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean addAll(Collection<? extends T> c) { | ||
return delegate().addAll(c); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean removeAll(Collection<?> c) { | ||
return delegate().removeAll(c); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean retainAll(Collection<?> c) { | ||
return delegate().retainAll(c); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public void clear() { | ||
delegate().clear(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return delegate().hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return obj == this || delegate().equals(obj); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return delegate().toString(); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
archunit/src/main/java/com/tngtech/archunit/base/ForwardingList.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,93 @@ | ||
/* | ||
* Copyright 2019 TNG Technology Consulting GmbH | ||
* | ||
* 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 com.tngtech.archunit.base; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.ListIterator; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
|
||
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS; | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public abstract class ForwardingList<T> extends ForwardingCollection<T> implements List<T> { | ||
protected ForwardingList() { | ||
} | ||
|
||
@Override | ||
protected abstract List<T> delegate(); | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public boolean addAll(int index, Collection<? extends T> c) { | ||
return delegate().addAll(index, c); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public T get(int index) { | ||
return delegate().get(index); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public T set(int index, T element) { | ||
return delegate().set(index, element); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public void add(int index, T element) { | ||
delegate().add(index, element); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public T remove(int index) { | ||
return delegate().remove(index); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public int indexOf(Object o) { | ||
return delegate().indexOf(o); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public int lastIndexOf(Object o) { | ||
return delegate().lastIndexOf(o); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public ListIterator<T> listIterator() { | ||
return delegate().listIterator(); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public ListIterator<T> listIterator(int index) { | ||
return delegate().listIterator(index); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public List<T> subList(int fromIndex, int toIndex) { | ||
return delegate().subList(fromIndex, toIndex); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
archunit/src/main/java/com/tngtech/archunit/base/ForwardingSet.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,31 @@ | ||
/* | ||
* Copyright 2019 TNG Technology Consulting GmbH | ||
* | ||
* 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 com.tngtech.archunit.base; | ||
|
||
import java.util.Set; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
|
||
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS; | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public abstract class ForwardingSet<T> extends ForwardingCollection<T> implements Set<T> { | ||
protected ForwardingSet() { | ||
} | ||
|
||
@Override | ||
protected abstract Set<T> delegate(); | ||
} |
Oops, something went wrong.