Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7801713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:01:52+00:00 2026-06-02T01:01:52+00:00

In my project, I have a class Device like this: public class Device {

  • 0

In my project, I have a class Device like this:

public class Device {
    private Set<String> abilities = new HashSet<String>();

    public Device(Set<String> abilities) {
        this.abilities = abilities;
    }

    public Set<String> getAbilities() {
        return abilities;
    }
}

I am initializing this Device class with:

Set<String> device1Abilities = new HashSet<String>();
device1Abilities.add("BadgeReader"); 
device1Abilities.add("TemperatureSensor");   
device1Abilities.add("xyz");
Device d1 = new Device(device1Abilities);

In my stringTemplateFile, I am retrieving abilities using

$device.abilities :{ sc | abilities.add("$sc$"); }$

which will generates following code =>

abilities.add("BadgeReader");
abilities.add("TemperatureSensor");
abilities.add("xyz");

Now, my requirement is —– I do not want to generate this line of code:

abilities.add("xyz");

What condition should I specify in

 $device.abilities :{ sc | abilities.add("$sc$"); }$

so that it does not generate that line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:01:53+00:00Added an answer on June 2, 2026 at 1:01 am

    That computation really belongs in the model so you should do the filtering of the list that you passed to the template. The template should not figure out which data to display. It should display the data that your model says it should display. hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope I'm asking this correctly: I have a project Projects.Client I have my class
I want to store some data from structures like this: class Project { ChildA
I am learning Ruby and I set up a controller like this: class Mobile::HomeController
I have a class project where I am using a VB.Net form to search
For a class project I have to use gcov to test coverage of a
I have a Class Library project and MVC project in the one solution. My
I have a class library project that references the version 4.1 Microsoft.Practices.Common dll. I
I have a class named project with the following data members. class Project {
I have a class library project which contains some content files configured with the
I have a webservice project (old asmx technology) in which I have a class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.