com.github.naoghuman.lib.action.internal.DefaultTransferData Maven / Gradle / Ivy
Show all versions of lib-action Show documentation
/*
* Copyright (C) 2017 Naoghuman
*
* 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.
*
* 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 .
*/
package com.github.naoghuman.lib.action.internal;
import com.github.naoghuman.lib.action.core.TransferData;
import java.util.Objects;
import java.util.Optional;
/**
* The {@code Implementation} from the {@code Interface} {@link com.github.naoghuman.lib.action.core.TransferData}.
* This {@code Implementation} is a simple readonly POJO. All attributes (expected {@code actionId})
* are optional, which means if the xy attribute is not set then an {@link java.util.Optional#empty()}
* will instead returned.
*
* An instance from this class can be generated with the fluent builder
* {@link com.github.naoghuman.lib.action.core.TransferDataBuilder} which is the
* preferred way to the an instance from this class.
*
* @author Naoghuman
* @see com.github.naoghuman.lib.action.core.TransferData
* @see com.github.naoghuman.lib.action.core.TransferDataBuilder
* @see java.util.Optional
*/
public final class DefaultTransferData implements TransferData {
/**
* Factory method to create an instance from the interface
* {@link com.github.naoghuman.lib.action.core.TransferData}.
*
* @param actionId mandory attribute which can't be NULL or EMPTY.
* @param booleanValue optional attribute which presented a {@code Boolean}.
* @param characterValue optional attribute which presented a {@code Character}.
* @param doubleValue optional attribute which presented a {@code Double}.
* @param integerValue optional attribute which presented a {@code Integer}.
* @param longValue optional attribute which presented a {@code Long}.
* @param objectValue optional attribute which presented a {@code Object}.
* @param stringValue optional attribute which presented a {@code String}.
* @param responseActionId optional attribute which presented the {@code actionId}
* which should be triggert as a {@code response}. If set
* then the value can't be NULL or EMPTY.
* @param loggingDisabled flag which decides if the {@code TransferData} should
* be logged during the {@link javafx.event.ActionEvent}
* or not.
* @return a configured instance from the {@code Interface} {@code TransferData}.
* @see com.github.naoghuman.lib.action.core.TransferData
* @see java.lang.Boolean
* @see java.lang.Character
* @see java.lang.Double
* @see java.lang.Integer
* @see java.lang.Long
* @see java.lang.Object
* @see java.lang.String
* @see java.util.Optional
* @see javafx.event.ActionEvent
*/
public static final TransferData create(
final String actionId, final Boolean booleanValue,
final Character characterValue, final Double doubleValue,
final Integer integerValue, final Long longValue,
final Object objectValue, final String stringValue,
final String responseActionId, final boolean loggingDisabled
) {
return new DefaultTransferData(actionId, booleanValue, characterValue,
doubleValue, integerValue, longValue, objectValue, stringValue,
responseActionId, loggingDisabled);
}
private final boolean loggingDisabled;
private final Optional booleanValue;
private final Optional characterValue;
private final Optional doubleValue;
private final Optional integerValue;
private final Optional longValue;
private final Optional