001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.model.enm.appgallery; 011 012import jakarta.annotation.Nonnull; 013 014import java.util.Collection; 015import java.util.List; 016import java.util.Locale; 017import java.util.Optional; 018import java.util.Set; 019import java.util.stream.Collectors; 020import java.util.stream.Stream; 021 022public enum AGProfileType { 023 INDIVIDUAL, 024 BUSINESS, 025 PAYER; 026 027 public boolean isIndividual() { 028 return AGProfileType.INDIVIDUAL.equals(this); 029 } 030 031 public boolean isPayer() { 032 return AGProfileType.PAYER.equals(this); 033 } 034 035 @Nonnull 036 public static AGProfileType find(String theType) { 037 try { 038 return valueOf(theType.toUpperCase(Locale.ROOT)); 039 } catch (NullPointerException | IllegalArgumentException e) { 040 return AGProfileType.BUSINESS; 041 } 042 } 043 044 @Nonnull 045 public static Set<AGProfileType> findAll(List<String> theProfileTypes) { 046 return Optional.ofNullable(theProfileTypes) 047 .map(Collection::stream) 048 .orElseGet(Stream::empty) 049 .map(AGProfileType::find) 050 .collect(Collectors.toSet()); 051 } 052}