mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-20 19:11:42 +01:00
refactor: replace anonymous types with lambdas
This commit is contained in:
@@ -34,24 +34,20 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -94,22 +90,16 @@ public class GitBranchesCommand extends AbstractGitCommand
|
||||
{
|
||||
List<Ref> refs = git.branchList().call();
|
||||
|
||||
branches = Lists.transform(refs, new Function<Ref, Branch>()
|
||||
{
|
||||
branches = Lists.transform(refs, ref -> {
|
||||
Branch branch = null;
|
||||
String branchName = GitUtil.getBranch(ref);
|
||||
|
||||
@Override
|
||||
public Branch apply(Ref ref)
|
||||
if (branchName != null)
|
||||
{
|
||||
Branch branch = null;
|
||||
String branchName = GitUtil.getBranch(ref);
|
||||
|
||||
if (branchName != null)
|
||||
{
|
||||
branch = new Branch(branchName, GitUtil.getId(ref.getObjectId()));
|
||||
}
|
||||
|
||||
return branch;
|
||||
branch = new Branch(branchName, GitUtil.getId(ref.getObjectId()));
|
||||
}
|
||||
|
||||
return branch;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -40,17 +40,9 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.Branches;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.*;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
import sonia.scm.template.Template;
|
||||
@@ -63,16 +55,16 @@ import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -310,16 +302,10 @@ public class GitRepositoryViewer
|
||||
.setPagingLimit(CHANGESET_PER_BRANCH)
|
||||
.getChangesets();
|
||||
|
||||
Iterable<ChangesetModel> changesets =
|
||||
Iterables.transform(cpr, new Function<Changeset,ChangesetModel>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public ChangesetModel apply(Changeset changeset)
|
||||
{
|
||||
return new ChangesetModel(changeset);
|
||||
}
|
||||
});
|
||||
Iterable<ChangesetModel> changesets =
|
||||
StreamSupport.stream(cpr.spliterator(), false)
|
||||
.map(ChangesetModel::new)
|
||||
.collect(Collectors.toList());
|
||||
//J+
|
||||
|
||||
model = new BranchModel(name, changesets);
|
||||
|
||||
@@ -37,35 +37,31 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.api.CommitCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.transport.ScmTransportProtocol;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserTestData;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -122,23 +118,7 @@ public class AbstractRemoteCommandTestBase
|
||||
{
|
||||
|
||||
// store reference to handle weak references
|
||||
proto = new ScmTransportProtocol(new Provider<HookEventFacade>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public HookEventFacade get()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}, new Provider<GitRepositoryHandler>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public GitRepositoryHandler get()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
proto = new ScmTransportProtocol(() -> null, () -> null);
|
||||
Transport.register(proto);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user