swim.uri.UriMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swim-uri Show documentation
Show all versions of swim-uri Show documentation
Uploads all artifacts belonging to configuration ':swim-uri:archives'
// Copyright 2015-2019 SWIM.AI inc.
//
// 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 swim.uri;
import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import swim.codec.Debug;
import swim.codec.Format;
import swim.codec.Output;
public abstract class UriMapper implements Iterable>, Map, Debug {
UriMapper() {
// stub
}
@Override
public abstract boolean isEmpty();
@Override
public abstract int size();
@Override
public boolean containsKey(Object key) {
return get(key) != null;
}
@Override
public abstract boolean containsValue(Object value);
public abstract T get(Uri uri);
public T get(String uri) {
return get(Uri.parse(uri));
}
@Override
public T get(Object key) {
if (key instanceof Uri) {
return get((Uri) key);
} else if (key instanceof String) {
return get((String) key);
} else {
return null;
}
}
@Override
public T put(Uri pattern, T value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(Map extends Uri, ? extends T> map) {
throw new UnsupportedOperationException();
}
@Override
public T remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
public abstract UriMapper merged(UriMapper that);
public UriMapper updated(Uri pattern, T value) {
return merged(from(pattern, value));
}
public UriMapper updated(UriPattern pattern, T value) {
return updated(pattern.toUri(), value);
}
public UriMapper updated(String pattern, T value) {
return updated(Uri.parse(pattern), value);
}
public abstract UriMapper removed(Uri pattern);
public UriMapper removed(UriPattern pattern) {
return removed(pattern.toUri());
}
public UriMapper removed(String pattern) {
return removed(Uri.parse(pattern));
}
public abstract UriMapper unmerged(UriMapper that);
@Override
public Set> entrySet() {
return new UriMapperEntrySet(this);
}
@Override
public Set keySet() {
return new UriMapperKeySet(this);
}
@Override
public Collection values() {
return new UriMapperValues(this);
}
@Override
public abstract Iterator> iterator();
public abstract Iterator keyIterator();
public abstract Iterator valueIterator();
@Override
public void debug(Output> output) {
output = output.write("UriMapper").write('.').write("empty").write('(').write(')');
for (Entry from : this) {
output = output.write('.').write("updated").write('(')
.debug(from.getKey().toString()).write(", ")
.debug(from.getValue()).write(')');
}
}
@Override
public String toString() {
return Format.debug(this);
}
private static UriMapper
© 2015 - 2025 Weber Informatics LLC | Privacy Policy