-
Notifications
You must be signed in to change notification settings - Fork 185
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
17 changed files
with
179 additions
and
242 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
31 changes: 1 addition & 30 deletions
31
scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixPatchImpl.scala
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 |
---|---|---|
@@ -1,37 +1,8 @@ | ||
package scalafix.internal.interfaces | ||
|
||
import java.util.UUID | ||
|
||
import scalafix.interfaces.ScalafixPatch | ||
import scalafix.Patch | ||
|
||
import scala.util.Try | ||
|
||
case class ScalafixPatchImpl(id: ScalafixPatchImpl.Id, patch: Patch) | ||
extends ScalafixPatch { | ||
case class ScalafixPatchImpl(patch: Patch) extends ScalafixPatch { | ||
override def kind(): String = patch.productPrefix | ||
|
||
override def getId: String = id.value | ||
|
||
} | ||
|
||
object ScalafixPatchImpl { | ||
|
||
case class Id(value: String) { | ||
assert(Id.isValid(value), s"Invalid format for ${getClass.getName}: $value") | ||
|
||
override def toString: String = value | ||
} | ||
|
||
object Id { | ||
def generate(): Id = Id(UUID.randomUUID().toString) | ||
|
||
def isValid(in: String): Boolean = Try(UUID.fromString(in)).isSuccess | ||
|
||
def from(in: String): Try[Id] = Try(Id(in)) | ||
} | ||
|
||
def from(patch: Patch): ScalafixPatchImpl = | ||
ScalafixPatchImpl(Id.generate(), patch) | ||
|
||
} |
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
Oops, something went wrong.