001/* 002 * (C) Copyright 2020 Nuxeo (http://nuxeo.com/) and others. 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 * 016 * Contributors: 017 * Nour AL KOTOB 018 */ 019package org.nuxeo.runtime.migration; 020 021import org.apache.commons.lang3.builder.EqualsBuilder; 022import org.apache.commons.lang3.builder.HashCodeBuilder; 023import org.nuxeo.runtime.migration.MigrationDescriptor.MigrationStepDescriptor; 024 025/** 026 * @since 11.2 027 */ 028public class MigrationStep { 029 030 protected final String id; 031 032 protected final String description; 033 034 protected final String descriptionLabel; 035 036 protected final String fromState; 037 038 protected final String toState; 039 040 protected MigrationStep(String id, String description, String descriptionLabel, String fromState, String toState) { 041 this.id = id; 042 this.description = description; 043 this.descriptionLabel = descriptionLabel; 044 this.fromState = fromState; 045 this.toState = toState; 046 } 047 048 public static MigrationStep from(MigrationStepDescriptor descriptor) { 049 return new MigrationStep(descriptor.getId(), descriptor.getDescription(), descriptor.getDescriptionLabel(), 050 descriptor.getFromState(), descriptor.getToState()); 051 } 052 053 public final String getId() { 054 return id; 055 } 056 057 public String getDescription() { 058 return description; 059 } 060 061 public String getDescriptionLabel() { 062 return descriptionLabel; 063 } 064 065 public String getFromState() { 066 return fromState; 067 } 068 069 public String getToState() { 070 return toState; 071 } 072 073 @Override 074 public int hashCode() { 075 return HashCodeBuilder.reflectionHashCode(this); 076 } 077 078 @Override 079 public boolean equals(Object obj) { 080 return EqualsBuilder.reflectionEquals(this, obj); 081 } 082 083 @Override 084 public String toString() { 085 return "MigrationStep [id=" + id + ", description=" + description + ", descriptionLabel=" + descriptionLabel 086 + ", fromState=" + fromState + ", toState=" + toState + "]"; 087 } 088 089}