
org.jsimpledb.parse.util.StripPrefixFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsimpledb-parse Show documentation
Show all versions of jsimpledb-parse Show documentation
JSimpleDB classes for parsing Java expressions.
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package org.jsimpledb.parse.util;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
/**
* Strips a prefix, which must match any input.
*/
public class StripPrefixFunction implements Function {
private final String prefix;
public StripPrefixFunction(String prefix) {
Preconditions.checkArgument(prefix != null, "null prefix");
this.prefix = prefix;
}
@Override
public String apply(String string) {
Preconditions.checkArgument(string != null, "null string");
if (!string.startsWith(this.prefix))
throw new IllegalArgumentException("string `" + string + "' does not have prefix `" + this.prefix + "'");
return string.substring(prefix.length());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy