All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jfxtras.icalendarfx.components.VComponentElement Maven / Gradle / Ivy

There is a newer version: 17-r1
Show newest version
package jfxtras.icalendarfx.components;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

import jfxtras.icalendarfx.VCalendar;
import jfxtras.icalendarfx.VElement;
import jfxtras.icalendarfx.components.DaylightSavingTime;
import jfxtras.icalendarfx.components.StandardTime;
import jfxtras.icalendarfx.components.VAlarm;
import jfxtras.icalendarfx.components.VComponent;
import jfxtras.icalendarfx.components.VComponentElement;
import jfxtras.icalendarfx.components.VEvent;
import jfxtras.icalendarfx.components.VFreeBusy;
import jfxtras.icalendarfx.components.VJournal;
import jfxtras.icalendarfx.components.VTimeZone;
import jfxtras.icalendarfx.components.VTodo;

/**
 * 

Enumerated type containing all the {@link VComponent} elements that can be in a {@link VCalendar}

* * @author David Bal * */ public enum VComponentElement { // MAIN COMPONENTS VEVENT ("VEVENT", VEvent.class), VTODO ("VTODO", VTodo.class), VJOURNAL ("VJOURNAL", VJournal.class), VTIMEZONE ("VTIMEZONE", VTimeZone.class), VFREEBUSY ("VFREEBUSY", VFreeBusy.class), DAYLIGHT_SAVING_TIME ("DAYLIGHT", DaylightSavingTime.class), STANDARD_TIME ("STANDARD", StandardTime.class), VALARM ("VALARM", VAlarm.class) ; // Map to match up name to enum private static final Map NAME_MAP = Arrays.stream(values()) .collect(Collectors.toMap( v -> v.toString(), v -> v)); public static VComponentElement fromName(String propertyName) { return NAME_MAP.get(propertyName.toUpperCase()); } // Map to match up class to enum private static final Map, VComponentElement> CLASS_MAP = Arrays.stream(values()) .collect(Collectors.toMap( v -> v.elementClass(), v -> v)); /** get enum from map */ public static VComponentElement fromClass(Class myClass) { VComponentElement p = CLASS_MAP.get(myClass); if (p == null) { throw new IllegalArgumentException(VComponentElement.class.getSimpleName() + " does not contain an enum to match the class:" + myClass.getSimpleName()); } return p; } /* * FIELDS */ private Class myClass; public Class elementClass() { return myClass; } private String name; @Override public String toString() { return name; } /* * CONSTRUCTOR */ VComponentElement(String name, Class myClass) { this.name = name; this.myClass = myClass; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy