Skip to content

Commit

Permalink
API extension
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jan 9, 2024
1 parent ea0aebd commit 618cf63
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public void iterateAllArtifacts (final String sGroupID,

public void initForRepo (final IRepoStorageWithToc aRepo)
{}

public boolean containsGroupAndArtifact (final String sGroupID,
final String sArtifactID)
{
return false;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.function.Consumer;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.commons.annotation.Nonempty;
import com.helger.commons.annotation.ReturnsMutableCopy;
Expand All @@ -45,6 +46,8 @@ public interface IRepoTopTocService
*/
void initForRepo (@Nonnull IRepoStorageWithToc aRepo);

boolean containsGroupAndArtifact (@Nullable String sGroupID, @Nullable String sArtifactID);

void iterateAllTopLevelGroupNames (@Nonnull Consumer <String> aGroupNameConsumer);

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.function.Consumer;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -31,6 +32,7 @@
import com.helger.commons.concurrent.SimpleReadWriteLock;
import com.helger.commons.error.list.ErrorList;
import com.helger.commons.state.ESuccess;
import com.helger.commons.string.StringHelper;
import com.helger.diver.repo.RepoStorageItem;
import com.helger.diver.repo.RepoStorageKey;
import com.helger.diver.repo.toptoc.jaxb.v10.RepoTopTocType;
Expand Down Expand Up @@ -132,6 +134,18 @@ private void _checkInited ()
throw new IllegalStateException ("This service was not properly initialized");
}

public boolean containsGroupAndArtifact (@Nullable final String sGroupID, @Nullable final String sArtifactID)
{
_checkInited ();

if (StringHelper.hasNoText (sGroupID))
return false;
if (StringHelper.hasNoText (sArtifactID))
return false;

return m_aRWLock.readLockedBoolean ( () -> m_aTopToc.containsGroupAndArtifact (sGroupID, sArtifactID));
}

public void iterateAllTopLevelGroupNames (@Nonnull final Consumer <String> aGroupNameConsumer)
{
ValueEnforcer.notNull (aGroupNameConsumer, "GroupNameConsumer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ public int getTopLevelGroupCount ()
return m_aTopLevelGroups.size ();
}

public void iterateAllTopLevelGroupNames (@Nonnull final Consumer <String> aGroupNameConsumer)
{
ValueEnforcer.notNull (aGroupNameConsumer, "GroupNameConsumer");

m_aTopLevelGroups.keySet ().forEach (aGroupNameConsumer);
}

@Nullable
private Group _getGroup (@Nonnull @Nonempty final String sGroupID)
{
Expand All @@ -126,6 +119,26 @@ private Group _getGroup (@Nonnull @Nonempty final String sGroupID)
return aGroup;
}

public boolean containsGroupAndArtifact (@Nonnull @Nonempty final String sGroupID,
@Nonnull @Nonempty final String sArtifactID)
{
ValueEnforcer.notEmpty (sGroupID, "GroupID");
ValueEnforcer.notEmpty (sArtifactID, "ArtifactID");

final Group aGroup = _getGroup (sGroupID);
if (aGroup == null)
return false;

return aGroup.m_aArtifacts.contains (sArtifactID);
}

public void iterateAllTopLevelGroupNames (@Nonnull final Consumer <String> aGroupNameConsumer)
{
ValueEnforcer.notNull (aGroupNameConsumer, "GroupNameConsumer");

m_aTopLevelGroups.keySet ().forEach (aGroupNameConsumer);
}

private void _recursiveIterateExistingSubGroups (@Nonnull @Nonempty final String sAbsoluteGroupID,
@Nonnull final Group aCurGroup,
@Nonnull final IRepoTopTocGroupNameConsumer aGroupNameConsumer,
Expand Down

0 comments on commit 618cf63

Please sign in to comment.