All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.vkorobkov.jfixtures.loader.FixtureValue Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.github.vkorobkov.jfixtures.loader;

import com.github.vkorobkov.jfixtures.util.StringUtil;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@EqualsAndHashCode
@Getter
public final class FixtureValue {
    public static final String PREFIX_SQL = "sql:";
    public static final String PREFIX_TEXT = "text:";

    private final Object value;
    private final ValueType type;

    public FixtureValue(Object value) {
        if (value instanceof String) {
            String str = (String)value;
            this.type = determineType(str);
            this.value = StringUtil.removePrefixes(str, PREFIX_SQL, PREFIX_TEXT);
        } else {
            this.value = value;
            this.type = ValueType.AUTO;
        }
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    private ValueType determineType(String value) {
        return value.startsWith(PREFIX_SQL) ? ValueType.SQL : ValueType.TEXT;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy