Here you can find the source of contains(final Collection
Parameter | Description |
---|---|
mimeTypes | A collection of MimeType s |
mimeType | The mime type to test |
public static boolean contains(final Collection<MimeType> mimeTypes, final MimeType mimeType)
//package com.java2s; /* Copyright (C) 2014 Reinventing Geospatial, Inc * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version.// ww w .j av a2 s . c o m * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>, * or write to the Free Software Foundation, Inc., 59 Temple Place - * Suite 330, Boston, MA 02111-1307, USA. */ import java.util.Collection; import javax.activation.MimeType; public class Main { /** * Checks if a specific {@link MimeType} is in a collection of mime types * * @param mimeTypes * A collection of {@link MimeType}s * @param mimeType * The mime type to test * @return True if the mime type is in the collection */ public static boolean contains(final Collection<MimeType> mimeTypes, final MimeType mimeType) { if (mimeTypes == null) { throw new IllegalArgumentException("The collection of mimeTypes cannot be null."); } if (mimeType == null) { throw new IllegalArgumentException("mimeType cannot be null."); } return mimeTypes.stream().filter(format -> format != null) .anyMatch(allowedImageOutputFormat -> allowedImageOutputFormat.match(mimeType)); } }