001/* 002 * Copyright 2022 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.calendar.icsreader.ical4j; 017 018import java.util.ArrayList; 019import java.util.Arrays; 020import java.util.List; 021import java.util.function.Supplier; 022 023import net.fortuna.ical4j.data.CalendarBuilder; 024import net.fortuna.ical4j.model.Parameter; 025import net.fortuna.ical4j.model.ParameterFactory; 026import net.fortuna.ical4j.model.parameter.Abbrev; 027import net.fortuna.ical4j.model.parameter.AltRep; 028import net.fortuna.ical4j.model.parameter.Cn; 029import net.fortuna.ical4j.model.parameter.CuType; 030import net.fortuna.ical4j.model.parameter.DelegatedFrom; 031import net.fortuna.ical4j.model.parameter.DelegatedTo; 032import net.fortuna.ical4j.model.parameter.Dir; 033import net.fortuna.ical4j.model.parameter.Display; 034import net.fortuna.ical4j.model.parameter.Encoding; 035import net.fortuna.ical4j.model.parameter.FbType; 036import net.fortuna.ical4j.model.parameter.Feature; 037import net.fortuna.ical4j.model.parameter.FmtType; 038import net.fortuna.ical4j.model.parameter.Label; 039import net.fortuna.ical4j.model.parameter.Language; 040import net.fortuna.ical4j.model.parameter.Member; 041import net.fortuna.ical4j.model.parameter.PartStat; 042import net.fortuna.ical4j.model.parameter.Range; 043import net.fortuna.ical4j.model.parameter.RelType; 044import net.fortuna.ical4j.model.parameter.Related; 045import net.fortuna.ical4j.model.parameter.Role; 046import net.fortuna.ical4j.model.parameter.Rsvp; 047import net.fortuna.ical4j.model.parameter.ScheduleAgent; 048import net.fortuna.ical4j.model.parameter.ScheduleStatus; 049import net.fortuna.ical4j.model.parameter.SentBy; 050import net.fortuna.ical4j.model.parameter.Type; 051import net.fortuna.ical4j.model.parameter.TzId; 052import net.fortuna.ical4j.model.parameter.Value; 053import net.fortuna.ical4j.model.parameter.Vvenue; 054 055//FIXME this class is a copy of the DefaultParameterFactorySupplier from ical4j, with the new Email parameter in the same package, without the javax.mail dependency 056//to be removed as soon as ical4j 4.0 is released 057//ical4j is licensed under the BSD license 058@SuppressWarnings("all") 059public class AmetysParameterFactorySupplier implements Supplier<List<ParameterFactory<?>>> 060{ 061 @SuppressWarnings("unchecked") 062 @Override 063 public List<ParameterFactory<?>> get() 064 { 065 List<ParameterFactory<?>> rfc5545 = Arrays.<ParameterFactory<?>>asList(new Abbrev.Factory(), 066 new AltRep.Factory(), 067 new Cn.Factory(), 068 new CuType.Factory(), 069 new DelegatedFrom.Factory(), 070 new DelegatedTo.Factory(), 071 new Dir.Factory(), 072 new Encoding.Factory(), 073 new FmtType.Factory(), 074 new FbType.Factory(), 075 new Language.Factory(), 076 new Member.Factory(), 077 new PartStat.Factory(), 078 new Range.Factory(), 079 new Related.Factory(), 080 new RelType.Factory(), 081 new Role.Factory(), 082 new Rsvp.Factory(), 083 new ScheduleAgent.Factory(), 084 new ScheduleStatus.Factory(), 085 new SentBy.Factory(), 086 new Type.Factory(), 087 new TzId.Factory(), 088 new Value.Factory(), 089 new Vvenue.Factory()); 090 091 092 List<ParameterFactory<?>> rfc7986 = Arrays.<ParameterFactory<?>>asList(new Display.Factory(), 093 new Email.Factory(), 094 new Feature.Factory(), 095 new Label.Factory()); 096 097 List<ParameterFactory<?>> factories = new ArrayList<>(rfc5545); 098 factories.addAll(rfc7986); 099 100 return factories; 101 } 102}