convertByMethod

mail@pastecode.io avatar
unknown
java
4 years ago
692 B
2
Indexable
Never
public <S> S convertBy(Function... args) {
        if (arg.getClass().getSimpleName().equals("ArrayList"))
            return (S) args[0].andThen(args[1]).andThen(args[2]).apply(arg);
        else if (arg.getClass().getSimpleName().equals("String")) {
            if (args.length == 1) return (S) args[0].apply(arg);
            else if (args.length == 2) return (S) args[0].andThen(args[1]).apply(arg);
            else if (args.length == 3) return (S) args[0].andThen(args[1]).andThen(args[2]).apply(arg);
            else if (args.length == 4)
                return (S) args[0].andThen(args[1]).andThen(args[2]).andThen(args[3]).apply(arg);
        }
        return null;
    }