Restore original license headers in Maven versioning package

This commit is contained in:
Minecrell 2018-07-01 20:39:10 +02:00 committed by LexManos
parent 97627e7fb9
commit eb94dc5c48
6 changed files with 122 additions and 117 deletions

View File

@ -16,15 +16,12 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
/** //I beleive this is a unique class except that it uses the same name so that ComparibleVersion can stay the same.
* Describes an artifact version in terms of its components, converts it to/from a string and //Best reference I could find: https://github.com/apache/maven/blob/3501485ed2280e30ba74eb9f0e1c6422b68a3228/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java
* compares two versions. //This entire package *should* be removed and updated to normal maven-artifact library in 1.13.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public interface ArtifactVersion public interface ArtifactVersion
extends Comparable<ArtifactVersion> extends Comparable<ArtifactVersion>
{ {

View File

@ -1,24 +1,27 @@
/* /*
* Minecraft Forge * Repackaged and some modifications done by Forge, see in-line comments.
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -102,19 +105,19 @@ public class ComparableVersion
this.value = new BigInteger( str ); this.value = new BigInteger( str );
} }
@Override @Override //Forge: Add @Override
public int getType() public int getType()
{ {
return INTEGER_ITEM; return INTEGER_ITEM;
} }
@Override @Override //Forge: Add @Override
public boolean isNull() public boolean isNull()
{ {
return BigInteger_ZERO.equals( value ); return BigInteger_ZERO.equals( value );
} }
@Override @Override //Forge: Add @Override
public int compareTo( Item item ) public int compareTo( Item item )
{ {
if ( item == null ) if ( item == null )
@ -138,7 +141,7 @@ public class ComparableVersion
} }
} }
@Override @Override //Forge: Add @Override
public String toString() public String toString()
{ {
return value.toString(); return value.toString();
@ -192,13 +195,13 @@ public class ComparableVersion
this.value = ALIASES.getProperty( value , value ); this.value = ALIASES.getProperty( value , value );
} }
@Override @Override //Forge: Add @Override
public int getType() public int getType()
{ {
return STRING_ITEM; return STRING_ITEM;
} }
@Override @Override //Forge: Add @Override
public boolean isNull() public boolean isNull()
{ {
return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 ); return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 );
@ -223,7 +226,7 @@ public class ComparableVersion
return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i ); return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i );
} }
@Override @Override //Forge: Add @Override
public int compareTo( Item item ) public int compareTo( Item item )
{ {
if ( item == null ) if ( item == null )
@ -247,7 +250,7 @@ public class ComparableVersion
} }
} }
@Override @Override //Forge: Add @Override
public String toString() public String toString()
{ {
return value; return value;
@ -262,18 +265,15 @@ public class ComparableVersion
extends ArrayList<Item> extends ArrayList<Item>
implements Item implements Item
{ {
/** private static final long serialVersionUID = 1L; //Forge: added to quiet warnings.
*
*/
private static final long serialVersionUID = 1L;
@Override @Override //Forge: Add @Override
public int getType() public int getType()
{ {
return LIST_ITEM; return LIST_ITEM;
} }
@Override @Override //Forge: Add @Override
public boolean isNull() public boolean isNull()
{ {
return ( size() == 0 ); return ( size() == 0 );
@ -295,7 +295,7 @@ public class ComparableVersion
} }
} }
@Override @Override //Forge: Add @Override
public int compareTo( Item item ) public int compareTo( Item item )
{ {
if ( item == null ) if ( item == null )
@ -340,7 +340,7 @@ public class ComparableVersion
} }
} }
@Override @Override //Forge: Add @Override
public String toString() public String toString()
{ {
StringBuilder buffer = new StringBuilder( "(" ); StringBuilder buffer = new StringBuilder( "(" );
@ -462,25 +462,25 @@ public class ComparableVersion
return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false ); return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false );
} }
@Override @Override //Forge: Add @Override
public int compareTo( ComparableVersion o ) public int compareTo( ComparableVersion o )
{ {
return items.compareTo( o.items ); return items.compareTo( o.items );
} }
@Override @Override //Forge: Add @Override
public String toString() public String toString()
{ {
return value; return value;
} }
@Override @Override //Forge: Add @Override
public boolean equals( Object o ) public boolean equals( Object o )
{ {
return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical ); return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical );
} }
@Override @Override //Forge: Add @Override
public int hashCode() public int hashCode()
{ {
return canonical.hashCode(); return canonical.hashCode();

View File

@ -16,7 +16,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
public class DefaultArtifactVersion implements ArtifactVersion public class DefaultArtifactVersion implements ArtifactVersion

View File

@ -1,24 +1,27 @@
/* /*
* Minecraft Forge * Repackaged by Forge, otherwise unchangeed
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/** /**
* Occurs when a version is invalid. * Occurs when a version is invalid.
* *

View File

@ -1,26 +1,28 @@
/* /*
* Minecraft Forge * Repackaged and some modifications done by Forge, see in-line comments.
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
import net.minecraft.util.text.translation.I18n; /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import net.minecraft.util.text.translation.I18n; //Forge: Added imports
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -40,7 +42,7 @@ public class Restriction
public static final Restriction EVERYTHING = new Restriction( null, false, null, false ); public static final Restriction EVERYTHING = new Restriction( null, false, null, false );
public Restriction( @Nullable ArtifactVersion lowerBound, boolean lowerBoundInclusive, @Nullable ArtifactVersion upperBound, public Restriction( @Nullable ArtifactVersion lowerBound, boolean lowerBoundInclusive, @Nullable ArtifactVersion upperBound, //Forge: Added @Nullable
boolean upperBoundInclusive ) boolean upperBoundInclusive )
{ {
this.lowerBound = lowerBound; this.lowerBound = lowerBound;
@ -49,7 +51,7 @@ public class Restriction
this.upperBoundInclusive = upperBoundInclusive; this.upperBoundInclusive = upperBoundInclusive;
} }
@Nullable @Nullable //Forge: Added @Nullable
public ArtifactVersion getLowerBound() public ArtifactVersion getLowerBound()
{ {
return lowerBound; return lowerBound;
@ -60,7 +62,7 @@ public class Restriction
return lowerBoundInclusive; return lowerBoundInclusive;
} }
@Nullable @Nullable //Forge: Added @Nullable
public ArtifactVersion getUpperBound() public ArtifactVersion getUpperBound()
{ {
return upperBound; return upperBound;
@ -184,7 +186,7 @@ public class Restriction
return true; return true;
} }
@Override @Override //Forge: Added @Override
public String toString() public String toString()
{ {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
@ -204,6 +206,7 @@ public class Restriction
return buf.toString(); return buf.toString();
} }
//Forge: Added toStringFriendly, uses Minecraft's localization engine to create user friendly localized message.
public String toStringFriendly() public String toStringFriendly()
{ {
if ( getLowerBound() == null && getUpperBound() == null ) if ( getLowerBound() == null && getUpperBound() == null )

View File

@ -1,25 +1,25 @@
/* /*
* Minecraft Forge * Repackaged and some modifications done by Forge, see in-line comments.
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package net.minecraftforge.fml.common.versioning; package net.minecraftforge.fml.common.versioning;
/* /*
* Modifications by cpw under LGPL 2.1 or later * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
import java.util.ArrayList; import java.util.ArrayList;
@ -27,8 +27,7 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import com.google.common.base.Joiner; import com.google.common.base.Joiner; //Forge: Add Imports
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -76,6 +75,7 @@ public class VersionRange
return new VersionRange( recommendedVersion, copiedRestrictions ); return new VersionRange( recommendedVersion, copiedRestrictions );
} }
//Forge: Added factory function
/** /**
* Factory method, for custom versioning schemes * Factory method, for custom versioning schemes
* @param version version * @param version version
@ -86,6 +86,7 @@ public class VersionRange
{ {
return new VersionRange(version, restrictions); return new VersionRange(version, restrictions);
} }
/** /**
* Create a version range from a string representation * Create a version range from a string representation
* <p/> * <p/>
@ -103,7 +104,7 @@ public class VersionRange
* @throws InvalidVersionSpecificationException * @throws InvalidVersionSpecificationException
* *
*/ */
public static VersionRange createFromVersionSpec( @Nullable String spec ) public static VersionRange createFromVersionSpec( @Nullable String spec ) //Forge: Added @Nullable
throws InvalidVersionSpecificationException throws InvalidVersionSpecificationException
{ {
if ( spec == null ) if ( spec == null )
@ -230,14 +231,10 @@ public class VersionRange
return restriction; return restriction;
} }
public static VersionRange createFromVersion( String version , ArtifactVersion existing) public static VersionRange createFromVersion( String version , ArtifactVersion existing) //Forge: Added existing argument
{ {
List<Restriction> restrictions = Collections.emptyList(); List<Restriction> restrictions = Collections.emptyList();
if (existing == null) return new VersionRange(existing != null ? existing : new DefaultArtifactVersion( version ), restrictions );
{
existing = new DefaultArtifactVersion( version );
}
return new VersionRange(existing , restrictions );
} }
/** /**
@ -473,19 +470,23 @@ public class VersionRange
return restrictions; return restrictions;
} }
@Override
//Forge: Removed getSelectedVersion and isSelectedVersion
@Override //Forge: Added @Override
public String toString() public String toString()
{ {
if ( recommendedVersion != null ) if ( recommendedVersion != null )
{ {
return recommendedVersion.getVersionString(); return recommendedVersion.getVersionString(); //Forge: Version string specifically.
} }
else else
{ {
return Joiner.on(',').join(restrictions); return Joiner.on(',').join(restrictions); //Forge: Changeed from iterator loop to joiner.
} }
} }
//Forge: Added friendly {localized} toString
public String toStringFriendly() public String toStringFriendly()
{ {
if ( recommendedVersion != null ) if ( recommendedVersion != null )
@ -539,7 +540,7 @@ public class VersionRange
return !restrictions.isEmpty() && recommendedVersion == null; return !restrictions.isEmpty() && recommendedVersion == null;
} }
@Override @Override //Forge: Added @Override
public boolean equals( Object obj ) public boolean equals( Object obj )
{ {
if ( this == obj ) if ( this == obj )
@ -561,7 +562,7 @@ public class VersionRange
return equals; return equals;
} }
@Override @Override //Forge: Added @Override
public int hashCode() public int hashCode()
{ {
int hash = 7; int hash = 7;
@ -570,11 +571,13 @@ public class VersionRange
return hash; return hash;
} }
//Forge: Added @isUnboundedAbove
public boolean isUnboundedAbove() public boolean isUnboundedAbove()
{ {
return restrictions.size() == 1 && restrictions.get(0).getUpperBound() == null && !restrictions.get(0).isUpperBoundInclusive(); return restrictions.size() == 1 && restrictions.get(0).getUpperBound() == null && !restrictions.get(0).isUpperBoundInclusive();
} }
//Forge: Added @getLowerBoundString
public String getLowerBoundString() public String getLowerBoundString()
{ {
return restrictions.size() == 1 ? restrictions.get(0).getLowerBound().getVersionString() : ""; return restrictions.size() == 1 ? restrictions.get(0).getLowerBound().getVersionString() : "";