-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates FrozenList/Map to use AbstractList/Map
- Loading branch information
Showing
4 changed files
with
44 additions
and
194 deletions.
There are no files selected for viewing
46 changes: 12 additions & 34 deletions
46
...t/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenList.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 |
---|---|---|
@@ -1,51 +1,29 @@ | ||
package org.openapijsonschematools.client.schemas.validation; | ||
|
||
import java.util.AbstractList; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class FrozenList<E> extends ArrayList<E> { | ||
public class FrozenList<E> extends AbstractList<E> { | ||
/* | ||
A frozen List | ||
Once schema validation has been run, indexed access returns values of the correct type | ||
If values were mutable, the types in those methods would not agree with returned values | ||
*/ | ||
private final List<E> list; | ||
public FrozenList(Collection<? extends E> m) { | ||
super(m); | ||
super(); | ||
list = new ArrayList<>(m); | ||
} | ||
|
||
public boolean add(E e) { | ||
throw new UnsupportedOperationException(); | ||
@Override | ||
public E get(int index) { | ||
return list.get(index); | ||
} | ||
|
||
public void add(int index, E element) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public E remove(int index) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean remove(Object o) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public void clear() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean addAll(Collection<? extends E> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean addAll(int index, Collection<? extends E> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean removeAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean retainAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(); | ||
@Override | ||
public int size() { | ||
return list.size(); | ||
} | ||
} |
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
47 changes: 13 additions & 34 deletions
47
src/main/resources/java/src/main/java/packagename/schemas/validation/FrozenList.hbs
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 |
---|---|---|
@@ -1,51 +1,30 @@ | ||
package {{{packageName}}}.schemas.validation; | ||
|
||
import java.util.AbstractList; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class FrozenList<E> extends ArrayList<E> { | ||
public class FrozenList<E> extends AbstractList<E> { | ||
/* | ||
A frozen List | ||
Once schema validation has been run, indexed access returns values of the correct type | ||
If values were mutable, the types in those methods would not agree with returned values | ||
*/ | ||
private final List<E> list; | ||
public FrozenList(Collection<? extends E> m) { | ||
super(m); | ||
super(); | ||
list = new ArrayList<>(m); | ||
} | ||
|
||
public boolean add(E e) { | ||
throw new UnsupportedOperationException(); | ||
@Override | ||
public E get(int index) { | ||
return list.get(index); | ||
} | ||
|
||
public void add(int index, E element) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public E remove(int index) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean remove(Object o) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public void clear() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean addAll(Collection<? extends E> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean addAll(int index, Collection<? extends E> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean removeAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public boolean retainAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(); | ||
@Override | ||
public int size() { | ||
return list.size(); | ||
} | ||
} | ||
|
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