package software.amazon.databrew.schedule; import software.amazon.awssdk.services.databrew.model.DescribeScheduleResponse; import software.amazon.awssdk.services.databrew.model.Schedule; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ModelHelper { public static ResourceModel constructModel(final DescribeScheduleResponse schedule) { Map tags = schedule.tags(); return ResourceModel.builder() .jobNames(schedule.jobNames()) .cronExpression(schedule.cronExpression()) .name(schedule.name()) .tags(tags != null ? buildModelTags(tags) : null) .build(); } public static ResourceModel constructModel(final Schedule schedule) { Map tags = schedule.tags(); return ResourceModel.builder() .jobNames(schedule.jobNames()) .cronExpression(schedule.cronExpression()) .name(schedule.name()) .tags(tags != null ? buildModelTags(tags) : null) .build(); } public static Map buildTagInputMap(final List tagList) { Map tagMap = new HashMap<>(); // return null if no Tag specified. if (tagList == null) return null; for (Tag tag : tagList) { tagMap.put(tag.getKey(), tag.getValue()); } return tagMap; } public static List buildModelTags(final Map tags) { List tagArrayList = new ArrayList(); if (tags == null) return null; tags.forEach((k, v) -> tagArrayList.add(Tag.builder().key(k).value(v).build())); return tagArrayList; } }