
at.molindo.notify.model.Param Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molindo-notify Show documentation
Show all versions of molindo-notify Show documentation
Extensible notification framework
The newest version!
/**
* Copyright 2010 Molindo 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 at.molindo.notify.model;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import javax.annotation.Nonnull;
import at.molindo.utils.data.HexUtils;
import at.molindo.utils.data.SerializationUtils;
import at.molindo.utils.data.StringUtils;
public abstract class Param {
private String _name;
private Class _type;
public static Param pString(String name) {
return new Param(name, String.class) {
@Override
protected String string(String object) {
return object;
}
@Override
protected String object(String string) {
return string;
}
@Override
protected ParamType type() {
return ParamType.STRING;
}
};
}
public static Param pInteger(String name) {
return new Param(name, Integer.class) {
@Override
protected Integer object(String string) {
return Integer.parseInt(string);
}
@Override
protected ParamType type() {
return ParamType.INTEGER;
}
};
}
public static Param pLong(String name) {
return new Param(name, Long.class) {
@Override
protected Long object(String string) {
return Long.parseLong(string);
}
@Override
protected ParamType type() {
return ParamType.LONG;
}
};
}
public static Param pDouble(String name) {
return new Param(name, Double.class) {
@Override
protected Double object(String string) {
return Double.parseDouble(string);
}
@Override
protected ParamType type() {
return ParamType.DOUBLE;
}
};
}
public static Param pFloat(String name) {
return new Param(name, Float.class) {
@Override
protected Float object(String string) {
return Float.parseFloat(string);
}
@Override
protected ParamType type() {
return ParamType.FLOAT;
}
};
}
public static Param pBoolean(String name) {
return new Param(name, Boolean.class) {
@Override
protected Boolean object(String string) {
return Boolean.parseBoolean(string);
}
@Override
protected ParamType type() {
return ParamType.BOOLEAN;
}
};
}
public static Param pCharacter(String name) {
return new Param(name, Character.class) {
@Override
protected Character object(String string) {
return string.charAt(0);
}
@Override
protected ParamType type() {
return ParamType.CHARACTER;
}
};
}
public static Param pURL(String name) {
return new Param(name, URL.class) {
@Override
protected URL object(String string) {
try {
return new URL(string);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@Override
protected ParamType type() {
return ParamType.URL;
}
};
}
public static Param
© 2015 - 2025 Weber Informatics LLC | Privacy Policy