Workaround for getting tests to work.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / ProjectAndTaskName.java
blob038023bd0389a2144e19e1c7e75f9743d508c5e0
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.plugin.multivm;
12 import org.gradle.api.Project;
13 import org.gradle.api.Task;
15 /**
16 * This holds the name of a project and task and is used for storing them
17 * for resolution as needed.
19 * This class is immutable.
21 * @since 2020/08/15
23 public final class ProjectAndTaskName
25 /** The project name. */
26 protected final String project;
28 /** The task name. */
29 protected final String task;
31 /**
32 * Initializes the holder.
34 * @param __project The project name.
35 * @param __task The task name.
36 * @throws NullPointerException On null arguments.
37 * @since 2020/08/15
39 public ProjectAndTaskName(String __project, String __task)
40 throws NullPointerException
42 if (__project == null || __task == null)
43 throw new NullPointerException("NARG");
45 this.project = __project;
46 this.task = __task;
49 /**
50 * {@inheritDoc}
51 * @since 2020/08/15
53 @Override
54 public int hashCode()
56 return this.project.hashCode() ^
57 this.task.hashCode();
60 /**
61 * {@inheritDoc}
62 * @since 2020/08/15
64 @Override
65 public boolean equals(Object __o)
67 if (__o == this)
68 return true;
70 if (!(__o instanceof ProjectAndTaskName))
71 return false;
73 ProjectAndTaskName o = (ProjectAndTaskName)__o;
74 return this.project.equals(o.project) &&
75 this.task.equals(o.task);
78 /**
79 * {@inheritDoc}
80 * @since 2020/08/15
82 @Override
83 public String toString()
85 return this.project + ":" + this.task;
88 /**
89 * Maps the project and task name.
91 * @param __project The project to get from.
92 * @param __task The task to use.
93 * @return The project and task name.
94 * @throws NullPointerException On null arguments.
95 * @since 2020/08/15
97 public static ProjectAndTaskName of(Project __project, String __task)
98 throws NullPointerException
100 if (__project == null || __task == null)
101 throw new NullPointerException("NARG");
103 return new ProjectAndTaskName(__project.getPath(), __task);
107 * Maps from a task.
109 * @param __task The task to use.
110 * @return The project and task name.
111 * @throws NullPointerException On null arguments.
112 * @since 2020/08/15
114 public static ProjectAndTaskName of(Task __task)
115 throws NullPointerException
117 if (__task == null)
118 throw new NullPointerException("NARG");
120 return ProjectAndTaskName.of(__task.getProject(), __task.getName());