private final Skillable skillable;
/**
- * Constrcutor with skill instance
+ * Constructor with skill instance
* <p>
* @param skillable An instance of a Skillable class
*/
--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.events.skill.update;
+
+import java.text.MessageFormat;
+import org.mxchange.jjobs.model.skill.Skillable;
+
+/**
+ * An event being fired when an administrator has added a new skill
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class AdminUpdatedSkillEvent implements ObservableAdminUpdatedSkillEvent {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 14_785_787_174_600_002L;
+
+ /**
+ * Instance of added skillable
+ */
+ private final Skillable skillable;
+
+ /**
+ * Constructor with skill instance
+ * <p>
+ * @param skillable An instance of a Skillable class
+ */
+ public AdminUpdatedSkillEvent (final Skillable skillable) {
+ // Validate parameter
+ if (null == skillable) {
+ // Throw NPE
+ throw new NullPointerException("Parameter 'skillable' is null"); //NOI18N
+ } else if (skillable.getSkillId() == null) {
+ // Throw it again
+ throw new NullPointerException("skillable.skillId is null"); //NOI18N
+ } else if (skillable.getSkillId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("skillable.skillId={0} is invalid", skillable.getSkillId())); //NOI18N
+ }
+
+ // Set it here
+ this.skillable = skillable;
+ }
+
+ @Override
+ public Skillable getSkillable () {
+ return this.skillable;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.events.skill.update;
+
+import java.io.Serializable;
+import org.mxchange.jjobs.model.skill.Skillable;
+
+/**
+ * An interface for events being fired when an administrator has added a skill
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableAdminUpdatedSkillEvent extends Serializable {
+
+ /**
+ * Getter for Skillable class field
+ * <p>
+ * @return An instance of a Skillable class
+ */
+ Skillable getSkillable ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.exceptions;
+
+/**
+ * An exception being thrown when a skill instance has already been found
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class SkillAlreadyAddedException extends Exception {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 42_895_928_956_700_002L;
+
+}
return skill1.compareTo(skill2);
}
+ /**
+ * Copies all fields exception created/updated timestamps from source
+ * Skillable instance to target instance all fields.
+ * <p>
+ * @param sourceSkillable Source instance of a Skillable class
+ * @param targetSkillable Target instance of a Skillable class
+ */
+ public static void copySkillData (final Skillable sourceSkillable, final Skillable targetSkillable) {
+ // Check that both parameters are not null
+ if (null == sourceSkillable) {
+ // Throw NPE
+ throw new NullPointerException("sourceSkillable is null"); //NOI18N
+ } else if (null == targetSkillable) {
+ // Throw NPE
+ throw new NullPointerException("targetSkillable is null"); //NOI18N
+ } else if (Objects.equals(sourceSkillable, targetSkillable)) {
+ // Throw IAE
+ throw new IllegalArgumentException("sourceSkillable and targetSkillable are the same"); //NOI18N
+ }
+
+ // Copy all fields
+ targetSkillable.setSkillId(sourceSkillable.getSkillId());
+ targetSkillable.setSkillLastLocked(sourceSkillable.getSkillLastLocked());
+ targetSkillable.setSkillName(sourceSkillable.getSkillName());
+ targetSkillable.setSkillStatus(sourceSkillable.getSkillStatus());
+ }
+
/**
* Utilities classes don't have constructors
*/