Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static Set<Long> getLongValues(String[] parameterValues, String message) {
        Set<Long> ids = null;
        if (parameterValues != null && parameterValues.length > 0) {
            ids = new HashSet<>();
            for (String parameter : parameterValues) {
                try {
                    Long id = Long.parseLong(parameter);
                    if (id > 0) {
                        ids.add(Long.parseLong(parameter));
                    }
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException(message);
                }
            }
        }
        return ids;
    }
}