How to model Bill of Material in Java2019 Community Moderator ElectionHow to represent a non binary tree and how to do LCA on that tree?Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java

Power Strip for Europe

Why does cron require MTA for logging?

Recommendation letter by significant other if you worked with them professionally?

PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?

Is it a Cyclops number? "Nobody" knows!

Why do we say ‘pairwise disjoint’, rather than ‘disjoint’?

Is it safe to abruptly remove Arduino power?

Conservation of Mass and Energy

What is Tony Stark injecting into himself in Iron Man 3?

What can I do if someone tampers with my SSH public key?

Why does liquid water form when we exhale on a mirror?

From an axiomatic set theoric approach why can we take uncountable unions?

Having the player face themselves after the mid-game

School performs periodic password audits. Is my password compromised?

How does Ehrenfest's theorem apply to the quantum harmonic oscillator?

Does an unused member variable take up memory?

Does a difference of tense count as a difference of meaning in a minimal pair?

Is this Paypal Github SDK reference really a dangerous site?

How can I get players to focus on the story aspect of D&D?

Haman going to the second feast dirty

Is it possible to find 2014 distinct positive integers whose sum is divisible by each of them?

What is better: yes / no radio, or simple checkbox?

Plausibility of Mushroom Buildings

Giving a career talk in my old university, how prominently should I tell students my salary?



How to model Bill of Material in Java



2019 Community Moderator ElectionHow to represent a non binary tree and how to do LCA on that tree?Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java










0















I am new in Java and I am going to write a Java program to model some kind of Bill of Materials. A Bill of Material will contain a name, and a list of another bill of materials. This is my BOM model:



public class BOM 
private String name;
private List<BOM> childBOMs;

public BOM(String name, List<BOM> childBOMs)
this.name = name;
childBOMs = childBOMs;


// getter setter



In the program, I have a map to hold all the bill of materials that I have created:



 private Map<String, BOM> bomMap;
private List<BOM> boms;

private void createBOM(String bomName, List<BOM> childBOMs)
if (!bomMap.containsKey(bomName))
bomMap.put(bomName, new BOM(bomName, childBOMs));
else
System.out.println("A BOM with the same name is already put in the system");




Now let's say I create two BOMs:



- BOM1
+ CBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Now in the map I should have two BOMs: BOM1 and CBOM1. Now is my question how can I link the CBOM1 object that I just created to the CBOM1 that in the BOM1 object, so that the BOM1 and my bomMap will become something like:



- BOM1
+ CBOM1
+ CCBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Of course I can do directly like bom1.getChildBOMs().get(0).setChildBOMs(cBOM1.getChildBOMs()) but I want to ask if there is any generic solution here do to this, because I can image that if I have a hundread of BOMs in the system and each of them have some child BOMs and each of child BOMs have some child-child-BOMs, it would be very difficult to handle all. Can someone give me some hint here? Thanks!










share|improve this question







New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

    – Sofo Gial
    Mar 6 at 14:56






  • 1





    thank you I will have a look on it

    – Joe
    Mar 6 at 15:21















0















I am new in Java and I am going to write a Java program to model some kind of Bill of Materials. A Bill of Material will contain a name, and a list of another bill of materials. This is my BOM model:



public class BOM 
private String name;
private List<BOM> childBOMs;

public BOM(String name, List<BOM> childBOMs)
this.name = name;
childBOMs = childBOMs;


// getter setter



In the program, I have a map to hold all the bill of materials that I have created:



 private Map<String, BOM> bomMap;
private List<BOM> boms;

private void createBOM(String bomName, List<BOM> childBOMs)
if (!bomMap.containsKey(bomName))
bomMap.put(bomName, new BOM(bomName, childBOMs));
else
System.out.println("A BOM with the same name is already put in the system");




Now let's say I create two BOMs:



- BOM1
+ CBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Now in the map I should have two BOMs: BOM1 and CBOM1. Now is my question how can I link the CBOM1 object that I just created to the CBOM1 that in the BOM1 object, so that the BOM1 and my bomMap will become something like:



- BOM1
+ CBOM1
+ CCBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Of course I can do directly like bom1.getChildBOMs().get(0).setChildBOMs(cBOM1.getChildBOMs()) but I want to ask if there is any generic solution here do to this, because I can image that if I have a hundread of BOMs in the system and each of them have some child BOMs and each of child BOMs have some child-child-BOMs, it would be very difficult to handle all. Can someone give me some hint here? Thanks!










share|improve this question







New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

    – Sofo Gial
    Mar 6 at 14:56






  • 1





    thank you I will have a look on it

    – Joe
    Mar 6 at 15:21













0












0








0








I am new in Java and I am going to write a Java program to model some kind of Bill of Materials. A Bill of Material will contain a name, and a list of another bill of materials. This is my BOM model:



public class BOM 
private String name;
private List<BOM> childBOMs;

public BOM(String name, List<BOM> childBOMs)
this.name = name;
childBOMs = childBOMs;


// getter setter



In the program, I have a map to hold all the bill of materials that I have created:



 private Map<String, BOM> bomMap;
private List<BOM> boms;

private void createBOM(String bomName, List<BOM> childBOMs)
if (!bomMap.containsKey(bomName))
bomMap.put(bomName, new BOM(bomName, childBOMs));
else
System.out.println("A BOM with the same name is already put in the system");




Now let's say I create two BOMs:



- BOM1
+ CBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Now in the map I should have two BOMs: BOM1 and CBOM1. Now is my question how can I link the CBOM1 object that I just created to the CBOM1 that in the BOM1 object, so that the BOM1 and my bomMap will become something like:



- BOM1
+ CBOM1
+ CCBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Of course I can do directly like bom1.getChildBOMs().get(0).setChildBOMs(cBOM1.getChildBOMs()) but I want to ask if there is any generic solution here do to this, because I can image that if I have a hundread of BOMs in the system and each of them have some child BOMs and each of child BOMs have some child-child-BOMs, it would be very difficult to handle all. Can someone give me some hint here? Thanks!










share|improve this question







New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am new in Java and I am going to write a Java program to model some kind of Bill of Materials. A Bill of Material will contain a name, and a list of another bill of materials. This is my BOM model:



public class BOM 
private String name;
private List<BOM> childBOMs;

public BOM(String name, List<BOM> childBOMs)
this.name = name;
childBOMs = childBOMs;


// getter setter



In the program, I have a map to hold all the bill of materials that I have created:



 private Map<String, BOM> bomMap;
private List<BOM> boms;

private void createBOM(String bomName, List<BOM> childBOMs)
if (!bomMap.containsKey(bomName))
bomMap.put(bomName, new BOM(bomName, childBOMs));
else
System.out.println("A BOM with the same name is already put in the system");




Now let's say I create two BOMs:



- BOM1
+ CBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Now in the map I should have two BOMs: BOM1 and CBOM1. Now is my question how can I link the CBOM1 object that I just created to the CBOM1 that in the BOM1 object, so that the BOM1 and my bomMap will become something like:



- BOM1
+ CBOM1
+ CCBOM1
+ CBOM2

- CBOM1
+ CCBOM1


Of course I can do directly like bom1.getChildBOMs().get(0).setChildBOMs(cBOM1.getChildBOMs()) but I want to ask if there is any generic solution here do to this, because I can image that if I have a hundread of BOMs in the system and each of them have some child BOMs and each of child BOMs have some child-child-BOMs, it would be very difficult to handle all. Can someone give me some hint here? Thanks!







java






share|improve this question







New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 6 at 14:46









JoeJoe

1




1




New contributor




Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Joe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

    – Sofo Gial
    Mar 6 at 14:56






  • 1





    thank you I will have a look on it

    – Joe
    Mar 6 at 15:21

















  • Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

    – Sofo Gial
    Mar 6 at 14:56






  • 1





    thank you I will have a look on it

    – Joe
    Mar 6 at 15:21
















Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

– Sofo Gial
Mar 6 at 14:56





Have you considered using a n-ary Tree? You can look here for inspiration: stackoverflow.com/questions/31779028/…

– Sofo Gial
Mar 6 at 14:56




1




1





thank you I will have a look on it

– Joe
Mar 6 at 15:21





thank you I will have a look on it

– Joe
Mar 6 at 15:21












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Joe is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025801%2fhow-to-model-bill-of-material-in-java%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Joe is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Joe is a new contributor. Be nice, and check out our Code of Conduct.












Joe is a new contributor. Be nice, and check out our Code of Conduct.











Joe is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025801%2fhow-to-model-bill-of-material-in-java%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко