If you think the Android project pequeno-android-spotify listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright 2015 ze-pequeno/*www.java2s.com*/
*
* 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 com.pequeno.android.spotify.api.utils;
import android.text.TextUtils;
import java.util.ArrayList;
publicclass EnumUtils
{
/**
* Hide constructor
*/private EnumUtils() {}
/**
* Create enum from string value by ignoring case
* @param value String value to convert
* @param values Available values
* @param <T> Enum type to return
* @return Enum corresponding to value
*/publicstatic <T extends Enum<T>> T create(String value, T[] values)
{
if (value == null) {
thrownew IllegalArgumentException();
}
for (T e : values) {
if (value.equalsIgnoreCase(e.toString())) {
return e;
}
}
thrownew IllegalArgumentException();
}
/**
* Concat enumeration list
* @param values Values
* @param <T> Enumeration type
* @return Values as string
*/publicstatic <T extends Enum<T>> String join(T[] values)
{
return join(values, ",");
}
/**
* Concat enumeration list
* @param values Values
* @param separator Separator
* @param <T> Enumeration type
* @return Values as string
*/publicstatic <T extends Enum<T>> String join(T[] values, String separator)
{
StringBuilder sb = new StringBuilder();
for (T v : values) {
if (sb.length() > 1) {
sb.append(separator);
}
sb.append(v.toString().toLowerCase());
}
return sb.toString();
}
}