-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
469 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/net/raphimc/minecraftauth/step/SameInputBiMergeStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This file is part of MinecraftAuth - https://github.com/RaphiMC/MinecraftAuth | ||
* Copyright (C) 2023 RK_01/RaphiMC and contributors | ||
* | ||
* This program 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; 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 net.raphimc.minecraftauth.step; | ||
|
||
import com.google.gson.JsonObject; | ||
import org.apache.http.client.HttpClient; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class SameInputBiMergeStep<I1 extends AbstractStep.StepResult<?>, I2 extends AbstractStep.StepResult<?>, O extends BiMergeStep.StepResult<I1, I2>> extends BiMergeStep<I1, I2, O> implements SameInputStep<I1, O> { | ||
|
||
protected final List<AbstractStep<?, ?>> steps1UntilSameInput = new ArrayList<>(); | ||
protected final List<AbstractStep<?, ?>> steps2UntilSameInput = new ArrayList<>(); | ||
|
||
public SameInputBiMergeStep(final String name, final AbstractStep<?, I1> prevStep1, final AbstractStep<?, I2> prevStep2) { | ||
super(name, prevStep1, prevStep2); | ||
|
||
if (this.prevStep2 != null) { | ||
this.steps1UntilSameInput.addAll(this.findCommonStep(this.prevStep, this.prevStep2)); | ||
this.steps2UntilSameInput.addAll(this.findCommonStep(this.prevStep2, this.prevStep)); | ||
} | ||
} | ||
|
||
@Override | ||
public O refresh(final HttpClient httpClient, final O result) throws Exception { | ||
if (!result.isExpired()) { | ||
return result; | ||
} | ||
|
||
final I1 prevResult1 = this.prevStep.refresh(httpClient, result.prevResult()); | ||
final I2 prevResult2 = this.refreshSecondaryStepChain(httpClient, prevResult1, result.prevResult2(), this.steps1UntilSameInput, this.steps2UntilSameInput); | ||
return this.applyStep(httpClient, prevResult1, prevResult2); | ||
} | ||
|
||
@Override | ||
public O getFromInput(final HttpClient httpClient, final Object input) throws Exception { | ||
final I1 prevResult1 = this.prevStep.getFromInput(httpClient, input); | ||
final I2 prevResult2 = this.applySecondaryStepChain(httpClient, prevResult1, this.steps1UntilSameInput, this.steps2UntilSameInput); | ||
return this.applyStep(httpClient, prevResult1, prevResult2); | ||
} | ||
|
||
@Override | ||
public JsonObject toJson(final O result) { | ||
final JsonObject json = this.toRawJson(result); | ||
this.removeDuplicateStepResultsFromJson(json, this.steps2UntilSameInput); | ||
return json; | ||
} | ||
|
||
@Override | ||
public O fromJson(final JsonObject json) { | ||
this.insertDuplicateStepResultsIntoJson(json, this.steps1UntilSameInput, this.steps2UntilSameInput); | ||
return this.fromRawJson(json); | ||
} | ||
|
||
} |
142 changes: 0 additions & 142 deletions
142
src/main/java/net/raphimc/minecraftauth/step/SameInputOptionalMergeStep.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.