Add models for commons lang/text's Str[ing]Lookup class

This commit is contained in:
Chris Smowton
2021-02-18 11:43:48 +00:00
parent 1580d23b2b
commit f749c31136
7 changed files with 319 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.text;
import java.util.Map;
public abstract class StrLookup<V> {
public static StrLookup<?> noneLookup() {
return null;
}
public static StrLookup<String> systemPropertiesLookup() {
return null;
}
public static <V> StrLookup<V> mapLookup(final Map<String, V> map) {
return null;
}
public abstract String lookup(String key);
}

View File

@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.text.lookup;
import java.util.function.BiFunction;
import java.util.function.Function;
public interface BiStringLookup<U> extends StringLookup {
default String lookup(final String key, final U object) {
return null;
}
}

View File

@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.text.lookup;
/**
* Lookups a String key for a String value.
* <p>
* This class represents the simplest form of a string to string map. It has a benefit over a map in that it can create
* the result on demand based on the key.
* </p>
* <p>
* For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the value
* on demand from the database.
* </p>
*
* @since 1.3
*/
@FunctionalInterface
public interface StringLookup {
String lookup(String key);
}

View File

@@ -0,0 +1,143 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.text.lookup;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
public final class StringLookupFactory {
public static final StringLookupFactory INSTANCE = new StringLookupFactory();
public static void clear() {
}
public void addDefaultStringLookups(final Map<String, StringLookup> stringLookupMap) {
}
public StringLookup base64DecoderStringLookup() {
return null;
}
public StringLookup base64EncoderStringLookup() {
return null;
}
public StringLookup base64StringLookup() {
return null;
}
public <R, U> BiStringLookup<U> biFunctionStringLookup(final BiFunction<String, U, R> biFunction) {
return null;
}
public StringLookup constantStringLookup() {
return null;
}
public StringLookup dateStringLookup() {
return null;
}
public StringLookup dnsStringLookup() {
return null;
}
public StringLookup environmentVariableStringLookup() {
return null;
}
public StringLookup fileStringLookup() {
return null;
}
public <R> StringLookup functionStringLookup(final Function<String, R> function) {
return null;
}
public StringLookup interpolatorStringLookup() {
return null;
}
public StringLookup interpolatorStringLookup(final Map<String, StringLookup> stringLookupMap,
final StringLookup defaultStringLookup, final boolean addDefaultLookups) {
return null;
}
public <V> StringLookup interpolatorStringLookup(final Map<String, V> map) {
return null;
}
public StringLookup interpolatorStringLookup(final StringLookup defaultStringLookup) {
return null;
}
public StringLookup javaPlatformStringLookup() {
return null;
}
public StringLookup localHostStringLookup() {
return null;
}
public <V> StringLookup mapStringLookup(final Map<String, V> map) {
return null;
}
public StringLookup nullStringLookup() {
return null;
}
public StringLookup propertiesStringLookup() {
return null;
}
public StringLookup resourceBundleStringLookup() {
return null;
}
public StringLookup resourceBundleStringLookup(final String bundleName) {
return null;
}
public StringLookup scriptStringLookup() {
return null;
}
public StringLookup systemPropertyStringLookup() {
return null;
}
public StringLookup urlDecoderStringLookup() {
return null;
}
public StringLookup urlEncoderStringLookup() {
return null;
}
public StringLookup urlStringLookup() {
return null;
}
public StringLookup xmlStringLookup() {
return null;
}
}