Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.anhth12.lambda.ml.param; import com.google.common.base.Preconditions; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * * @author Tong Hoang Anh */ final class Unordered<T> implements HyperParamValues<T>, Serializable { private final List<T> values; Unordered(Collection<T> values) { Preconditions.checkNotNull(values); Preconditions.checkArgument(!values.isEmpty()); this.values = new ArrayList<>(values); } @Override public List<T> getTrialValues(int num) { Preconditions.checkArgument(num > 0); return num < values.size() ? values.subList(0, num) : values; } @Override public String toString() { return "Unordered[..." + getTrialValues(3) + "...]"; } }