Package com.sudicode.fb2gh.migrate
Class Migrator.Builder
- java.lang.Object
-
- com.sudicode.fb2gh.common.AbstractBuilder<Migrator>
-
- com.sudicode.fb2gh.migrate.Migrator.Builder
-
- Enclosing class:
- Migrator
public static final class Migrator.Builder extends AbstractBuilder<Migrator>
Builder used to instantiateMigrator
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Migrator.Builder
afterMigrate(BiConsumer<FBCase,GHIssue> afterMigrate)
After migrating a case to GitHub, perform some action specified by the givenBiConsumer
.Migrator
build()
Migrator.Builder
closeIf(Predicate<FBCase> closeIf)
Migrator.Builder
dateFormat(DateFormat dateFormat)
Format timestamps using the givenDateFormat
.Migrator.Builder
exceptionHandler(BiConsumer<FBCase,Exception> exceptionHandler)
If migrating a case causes anException
to be thrown, catch and handle it using the givenBiConsumer
.Migrator.Builder
fbAttachmentConverter(FBAttachmentConverter fbAttachmentConverter)
Migrator.Builder
fbCaseLabeler(FBCaseLabeler fbCaseLabeler)
Migrator.Builder
migrateIf(Predicate<FBCase> migrateIf)
Only migrate FogBugz cases that pass the givenPredicate
.Migrator.Builder
postDelay(long postDelay)
Migrator.Builder
usernameMap(Map<String,String> usernameMap)
Map FogBugz names to GitHub usernames.
-
-
-
Method Detail
-
fbAttachmentConverter
public Migrator.Builder fbAttachmentConverter(FBAttachmentConverter fbAttachmentConverter)
- Parameters:
fbAttachmentConverter
- TheFBAttachmentConverter
to use- Returns:
- This object
-
fbCaseLabeler
public Migrator.Builder fbCaseLabeler(FBCaseLabeler fbCaseLabeler)
- Parameters:
fbCaseLabeler
- TheFBCaseLabeler
to use- Returns:
- This object
-
closeIf
public Migrator.Builder closeIf(Predicate<FBCase> closeIf)
After migrating a FogBugz case, close the corresponding GitHub issue if theFBCase
passes the givenPredicate
. By default, the GitHub issue will be closed if the FogBugz case is closed.- Parameters:
closeIf
- ThePredicate
to use- Returns:
- This object
-
usernameMap
public Migrator.Builder usernameMap(Map<String,String> usernameMap)
Map FogBugz names to GitHub usernames.- Parameters:
usernameMap
- AMap
wherekey
is a FogBugz name andvalue
is the corresponding GitHub username.- Returns:
- This object
-
postDelay
public Migrator.Builder postDelay(long postDelay)
- Parameters:
postDelay
- Number of milliseconds to wait after posting an issue or comment, to avoid abuse detection.- Returns:
- This object
- Throws:
IllegalArgumentException
- ifpostDelay
is negative
-
migrateIf
public Migrator.Builder migrateIf(Predicate<FBCase> migrateIf)
Only migrate FogBugz cases that pass the givenPredicate
. By default, all cases will be migrated.- Parameters:
migrateIf
- ThePredicate
to use- Returns:
- This object
-
afterMigrate
public Migrator.Builder afterMigrate(BiConsumer<FBCase,GHIssue> afterMigrate)
After migrating a case to GitHub, perform some action specified by the givenBiConsumer
.- Parameters:
afterMigrate
-BiConsumer
to use. TheBiConsumer
receives (1) the FogBugz case that was migrated, and (2) the GitHub issue that was posted.- Returns:
- This object
-
exceptionHandler
public Migrator.Builder exceptionHandler(BiConsumer<FBCase,Exception> exceptionHandler)
If migrating a case causes anException
to be thrown, catch and handle it using the givenBiConsumer
. If no further exceptions are thrown, the migration process will continue as normal after being handled in this way. By default,Exceptions
are propagated upwards as is (thus ending the migration process).- Parameters:
exceptionHandler
-BiConsumer
to use. TheBiConsumer
receives (1) the FogBugz case that was attempted to be migrated, and (2) the exception thrown.- Returns:
- This object
-
dateFormat
public Migrator.Builder dateFormat(DateFormat dateFormat)
Format timestamps using the givenDateFormat
. By default, they will be formatted as follows:4/18/2017 1:29 PM EDT
. (The time zone will vary based on the JVM default.)Note: The default
DateFormat
is thread-safe. Should this method be invoked, the newDateFormat
may no longer be thread-safe. If using this configuration option, it is recommended to avoid multithreaded access of the resultingMigrator
.- Parameters:
dateFormat
-DateFormat
to use.- Returns:
- This object
-
build
public Migrator build()
- Specified by:
build
in classAbstractBuilder<Migrator>
- Returns:
- An instance of T.
-
-