简体   繁体   English

如何将StringBuilder令牌与多个Java字符串进行比较?

[英]How to compare StringBuilder tokens with multiple java strings?

  1. My video will be published in all or any one or any two or any three of the below departments like 我的视频将在以下所有部门或任何一个或任何两个或三个部门中发布,例如

    Test1,Test2,Test3,Test4 etc... Test1,Test2,Test3,Test4等...

  2. Programmatically I will fetch all the department names for my video and constructed as Java StringBuilder as below: 我将以编程方式获取视频的所有部门名称,并按以下方式构造为Java StringBuilder:

    Test1,Test2,Test3,Test4 etc. Test1,Test2,Test3,Test4等

  3. These departments has privacy values of one of the below enum constants: PUBLIC,PROTECTED,PRIVATE. 这些部门的隐私值是下列枚举常量之一:PUBLIC,PROTECTED,PRIVATE。

  4. If my department is public then video privacy is public. 如果我的部门是公开的,则视频隐私是公开的。

  5. If my department is protected then video privacy is protected. 如果我的部门受到保护,则视频隐私受到保护。
  6. If my department is private then video privacy is private. 如果我的部门是私人的,那么视频隐私是私人的。

I can set video privacy as specified above if my video is published in single department. 如果我的视频是在单个部门发布的,那么我可以按照上面的指定设置视频隐私。 But if my video is published in more than one department and then one department privacy is public another department privacy is protected then I need to set it as protected considering the highest value. 但是,如果我的视频在多个部门发布,那么一个部门的隐私是公开的,另一个部门的隐私受到保护,那么我需要考虑最高价值将其设置为受保护。

How to manage all these conditions like: 如何管理所有这些条件,例如:

  1. If privacy is public, private, protected then set video privacy as private 如果隐私是公开的,私有的,受保护的,则将视频隐私设置为私有
  2. If privacy is public, public, protected then set video privacy as protected like these combinations 如果隐私是公开的,公开的,受保护的,则将视频隐私设置为受保护,就像这些组合

Here is the code which gets all ids and privacies 这是获取所有ID和隐私的代码

List<Integer> newdepList = new ArrayList<Integer>();
    if(depName != null) {
        mediaVO.setDepNames(depName.toString());
        StringTokenizer st1 = new StringTokenizer(depName.toString(),",");
            if(depName.toString().contains(",")) {
                System.out.println("Media is assigned to more than one dep" + depName );
                while(st1.hasMoreTokens()) {
                    depname= st1.nextToken();
                    System.out.println("depname"+depname);
                    if(depname!= null) {
                    ListResponse resp = fetchDepDetails(depname);
                        if(resp.totalCount >= 1) {
                            for(Department dep:resp.objects) {
                                int rootdepId = Integer.valueOf(properties.getProperty("dep.id"));
                                if(dep.parentId == rootdepid|| dep.id == rootdepId) {
                                    newdepList.add(dep.id);
                                    //System.out.println("Department Id :::::::"+dep.id);
                                    //PrivacyType pri = fetchDepPrivacy(dep.id);
                                    //System.out.println("Privacy for the retrieved channels ----->"+pri);
                                }
                            }
                        }
                    }
                }

Thanks in advance, Sakuntala 在此先感谢,Sakuntala

maybe it makes sense to have your Visibility in an enum, where you can utilize the .ordinal() of each enum value ? 也许将您的可见性包含在枚举中是有意义的,在这里您可以利用每个枚举的.ordinal()? then if you have a list of departments departments.stream().map(d -> d.visivility().ordinal()).min().get() 那么如果您有部门departments.stream().map(d -> d.visivility().ordinal()).min().get()的列表部门departments.stream().map(d -> d.visivility().ordinal()).min().get()

and use Visibility.values()[i] in a convinient way around/inside the stream 并以方便的方式在流周围/内部使用Visibility.values()[i]

best atanas 最好的阿塔纳斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM